aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xScripts/.local/scripts/create_backup3
-rwxr-xr-xScripts/.local/scripts/do_backup15
-rw-r--r--SystemD/.config/systemd/user/backup.service2
-rw-r--r--SystemD/.config/systemd/user/backup.timer1
4 files changed, 18 insertions, 3 deletions
diff --git a/Scripts/.local/scripts/create_backup b/Scripts/.local/scripts/create_backup
index cde5a03..7a1309d 100755
--- a/Scripts/.local/scripts/create_backup
+++ b/Scripts/.local/scripts/create_backup
@@ -2,8 +2,7 @@
set -xe
-dir=$2/backup
-arch=$2/archive
+dir=/media/hdd/backup
name="$(date +%F)-$(date +%T)-$(basename $1).tar.xz"
XZ_OPT='-T0 -9' tar -Jcvf $dir/$name $1
diff --git a/Scripts/.local/scripts/do_backup b/Scripts/.local/scripts/do_backup
new file mode 100755
index 0000000..0d85694
--- /dev/null
+++ b/Scripts/.local/scripts/do_backup
@@ -0,0 +1,15 @@
+#!/usr/bin/env sh
+
+set -xe
+
+dir="/media/hdd/backup/$(date +%F)/$(date +%T)"
+folders="$HOME/Code $HOME/Dotfiles $HOME/Downloads $HOME/Media $HOME/Pictures $HOME/Projects $HOME/Text"
+
+mkdir -p $dir
+
+for name in $folders
+do
+ out_name=$dir/$(basename $name).tar.xz
+ XZ_OPT='-T0 -9' tar -Jcvf $out_name -C $name .
+done
+
diff --git a/SystemD/.config/systemd/user/backup.service b/SystemD/.config/systemd/user/backup.service
index d3bb8ed..0b44727 100644
--- a/SystemD/.config/systemd/user/backup.service
+++ b/SystemD/.config/systemd/user/backup.service
@@ -3,4 +3,4 @@ Description=Taking backup
[Service]
Type=simple
-ExecStart=/usr/bin/rsync -a --delete --quiet /home/oreo /media/hdd/backup
+ExecStart=%h/.local/scripts/do_backup
diff --git a/SystemD/.config/systemd/user/backup.timer b/SystemD/.config/systemd/user/backup.timer
index 2ddee9d..bf44b99 100644
--- a/SystemD/.config/systemd/user/backup.timer
+++ b/SystemD/.config/systemd/user/backup.timer
@@ -4,6 +4,7 @@ Description=Run backup weekly
[Timer]
OnBootSec=15min
OnUnitActiveSec=1w
+Unit=backup.service
[Install]
WantedBy=timers.target