Files from Blogpost
This commit is contained in:
15
systemd/system/autobackup.service
Normal file
15
systemd/system/autobackup.service
Normal file
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Backup /home to USB-Stick
|
||||
After=network.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
Environment="PARTUUID=7b2d5cb6-01" "MOUNTPOINT=/mnt/backup" "SOURCE=/home"
|
||||
ExecStart=/usr/local/bin/autobackup.sh
|
||||
StandardOutput=append:/var/log/autobackup.log
|
||||
StandardError=append:/var/log/autobackup_error.log
|
||||
Restart=no
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
14
usr/local/bin/autobackup.sh
Executable file
14
usr/local/bin/autobackup.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
echo "mounting ${PARTUUID} to ${MOUNTPOINT}"
|
||||
mount -t ext4 PARTUUID="${PARTUUID}" ${MOUNTPOINT}
|
||||
|
||||
if ! mountpoint -q ${MOUNTPOINT} ; then
|
||||
echo "Backup Stick not mounted" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "syncing ${SOURCE} to ${MOUNTPOINT}"
|
||||
rsync -a -v -z --delete ${SOURCE} ${MOUNTPOINT}
|
||||
|
||||
umount ${MOUNTPOINT}
|
||||
Reference in New Issue
Block a user