piframe/docs/restic.md

65 lines
1.7 KiB
Markdown

# Backups via restic
The below commands will setup a **local** backup of your photo frame using ```restic```.
## Important Considerations
* ```restic``` can use a bit of memory, you'll want at least 2Gb of ram on your Raspberry Pi to use this setup
* This setup does **NOT** include photos as part of the backup to keep backup sizes down
* This seutp assumes you have cron setup and runs the backup at 0700 every day
## Setup
``` sh
########################################
# restic backups
########################################
wget https://github.com/restic/restic/releases/download/v0.9.6/restic_0.9.6_linux_arm64.bz2
bunzip2 restic_0.9.6_linux_arm64.bz2
mv restic_0.9.6_linux_arm64 /usr/local/bin/restic
chmod a+x /usr/local/bin/restic
restic self-update
btrfs subvolume create /tank/backup
restic init -r /tank/backup
cat > /root/restic_backup.sh <<EOF
#!/bin/bash
MACHINE=picture-frame
ZONE=root
export RESTIC_REPOSITORY=/tank/backup/
export RESTIC_PASSWORD=testing1234
/usr/local/bin/restic backup -v -q \
--tag $MACHINE --tag $ZONE \
/ \
--exclude /run \
--exclude /snapshots \
--exclude /tank \
--exclude /scratch \
--exclude /proc \
--exclude /sys \
--exclude /var/lib/schroot/mount \
--exclude /var/lib/docker \
--exclude /var/lib/lxcfs \
--exclude /mnt \
--exclude /root/.cache \
/usr/local/bin/restic forget -v \
--tag $MACHINE --tag $ZONE \
--keep-daily=7 \
--keep-weekly=4 \
--keep-monthly=12 \
--keep-yearly 1
# This can take a very, very long time
/usr/local/bin/restic prune && /usr/local/bin/restic check
EOF
chmod a+x /root/restic_backup.sh
crontab -e
0 7 * * * /root/restic_backup.sh
```