commit c160b3080d74226907c9488f7fcd1698729014d6
parent de33ea277639cc8afa88f3a00a7d58681f7f52c4
Author: Claudio Alessi <smoppy@gmail.com>
Date: Sat, 22 May 2021 11:36:25 +0200
[mkbkp] Call onfinish callback if exists
Diffstat:
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
@@ -296,6 +296,20 @@ ${HOME}/.config/chromium/Default/Bookmarks
GITREPOS="
git@github.com:clamiax/scripts.git
"
+
+onfinish() {
+ t="$1.tar.bz2"
+
+ echo -n "Compressing to $t..."
+ tar jcf "$t" "$1"
+ echo " done"
+
+ echo -n "Uploading to a backup server..."
+ scp "$t" user@host:/path/of/backup
+ echo " done"
+
+ echo "Completed."
+}
```
mkbkp only supports backup of files, directories and git repositories. Though
diff --git a/src/mkbkp b/src/mkbkp
@@ -58,6 +58,10 @@ mexec() {
done
}
+isfunc() {
+ type "$1" |grep -q function
+}
+
main() {
cfg="$1"
[ -z "$cfg" ] && cfg=~/.mkbkprc
@@ -75,6 +79,8 @@ main() {
cd "$OPWD"
echo " done."
+
+ isfunc "onfinish" && onfinish "$BKPDIR"
}
main "$@"