aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2022-09-03 10:02:55 +0300
committerJoursoir <chat@joursoir.net>2022-09-03 10:04:11 +0300
commit3181036d8fbfd689ebc8e9d1e104941819643288 (patch)
tree089153600fb84fb7ae62f72385cc6a36a761e3e2
parentfe4bfa62a9042f0ee907975552cc2e2e86628fb1 (diff)
downloaddotfiles-3181036d8fbfd689ebc8e9d1e104941819643288.tar.gz
dotfiles-3181036d8fbfd689ebc8e9d1e104941819643288.tar.bz2
dotfiles-3181036d8fbfd689ebc8e9d1e104941819643288.zip
bin: add script for remote backup
-rwxr-xr-xbin/do-backup.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/bin/do-backup.sh b/bin/do-backup.sh
new file mode 100755
index 0000000..02350e5
--- /dev/null
+++ b/bin/do-backup.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+#
+# Dependencies: 'rsync'
+
+backupdir=/mnt/storage/backups
+logdir=$backupdir/logs
+originserver="user@example.com"
+tdate=$(date +%Y%m%d)
+
+# Rsync options:
+# a = archive mode (symbolic links, attributes, permissions,
+# ownerships, etc. are preserved in the transfer)
+# z = compress file data during the transfer
+# v = increase verbosity
+# h = output numbers in a human-readable format
+#
+# A trailing *slash* on the _source_ changes this behavior to avoid
+# creating an additional directory level at the _destination_.
+mkdir -p $backupdir/$tdate && \
+rsync -azvh --progress $originserver:/ \
+ --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} \
+ "$backupdir/$tdate" \
+ --log-file="$logdir/$tdate.log"