Backup
Use restic and a systemd timer to periodically back up my home folder.
Prerequisites
Install rclone and restic. On Arch Linux, run:
sudo pacman -S rclone restic
Rclone
Rclone ("rsync for cloud storage") is a command-line program to sync files and directories to and from different cloud storage providers. ---From its repo
- Run
rclone configand let it set things up for you. rclone mount- Example:
rclone mount mc:/ /home/leo/mnt/Onedrive --vfs-cache-mode full
- Example:
Restic
Restic is a backup program that is fast, efficient and secure. ---From its repo
-
Use with rclone
-
I wrote a shell script to save some typing.
# !/usr/bin/env bash
restic -r rclone:mc:restic --no-scan --password-file=/home/leo/.config/restic/pw.txt \
--exclude-file=/home/leo/.config/restic/exclude.txt backup /home/leo
systemd timer
See the Arch Wiki page.
Basically, it's like cron but better integrated with systemd.
Create backup.timer in ~/.config/systemd/user
[Unit]
Description=Use Restic to back up my home folder daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
Persistent=true means it will run at least once a day (or at next
login).
Use backup.timer to trigger backup.service:
[Unit]
Description=Use Restic to back up my home folder daily
[Service]
ExecStart=/home/leo/bin/backup
Type=oneshot
Then run systemctl enable backup.timer --user to enable the timer.
Everything is set now.
To verify, run systemctl list-timers --all --user to check the status
of backup.timer:
NEXT LEFT LAST PASSED UNIT ACTIVATES
Sun 2022-11-20 00:00:00 CST 9h left Sat 2022-11-19 10:06:17 CST 4h 1min ago backup.timer backup.service
1 timers listed.