2018-08-16 18:30:16 +00:00
|
|
|
# Borg Backups
|
|
|
|
|
|
|
|
The BETTER backup solution.
|
|
|
|
|
|
|
|
**BE MINDFUL OF RUNNING BORG. IT CAN CAUSE PROBLEMS WITH DISK IOPS AND RAM USAGE. BEST USED WHEN THE MACHINE IS KNOWN TO BE IDLE!!!**
|
|
|
|
|
|
|
|
## Inspiration / Further Reading
|
|
|
|
|
|
|
|
- [https://borgbackup.readthedocs.io/en/stable/installation.html#from-source](https://borgbackup.readthedocs.io/en/stable/installation.html#from-source)
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
2018-09-17 20:29:55 +00:00
|
|
|
*Note: we are downloading pre-built borg images from the main lollipop cloud servers in this step instead of building it from scratch*
|
|
|
|
|
|
|
|
### arm32v7 boards
|
2018-08-16 18:30:16 +00:00
|
|
|
|
|
|
|
``` bash
|
|
|
|
|
2018-09-17 20:29:55 +00:00
|
|
|
wget -O /usr/local/bin/borg https://dl.lollipopcloud.solutions/api/download/borg/borg-1.1.7-arm32v7-debian-stretch
|
2018-08-16 18:30:16 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
2018-09-17 20:29:55 +00:00
|
|
|
### arm64v8 boards
|
|
|
|
|
|
|
|
``` bash
|
2018-08-16 18:30:16 +00:00
|
|
|
|
2018-09-17 20:29:55 +00:00
|
|
|
wget -O /usr/local/bin/borg https://dl.lollipopcloud.solutions/api/download/borg/borg-1.1.7-arm64v8-debian-stretch
|
|
|
|
|
|
|
|
```
|
2018-08-16 18:30:16 +00:00
|
|
|
|
2018-09-17 20:29:55 +00:00
|
|
|
### All boards
|
2018-08-16 18:30:16 +00:00
|
|
|
|
2018-09-17 20:29:55 +00:00
|
|
|
``` bash
|
|
|
|
|
|
|
|
chmod a+x /usr/local/bin/borg
|
|
|
|
|
|
|
|
```
|
2018-08-16 18:30:16 +00:00
|
|
|
|
|
|
|
## Initialize Backup Repo
|
|
|
|
|
|
|
|
*Note: assumes you have a ```/tank``` on external disk*
|
|
|
|
|
|
|
|
``` bash
|
|
|
|
|
|
|
|
cd /tank/backup
|
|
|
|
borg init --encryption none . # No crypto/auth for speed (see docs for more infos)
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## Backup Script
|
|
|
|
|
|
|
|
Setup a backup script that backs up everything (**note the excludes**) to the initialized repository.
|
|
|
|
|
|
|
|
Run ```/root/borg_backup.sh``` any time you want to take a backup.
|
|
|
|
|
|
|
|
``` bash
|
|
|
|
|
|
|
|
cat > /root/borg_backup.sh <<EOF
|
|
|
|
#!/bin/sh
|
|
|
|
REPOSITORY=/tank/backup
|
|
|
|
|
|
|
|
# Backup all of /home and /var/www except a few
|
|
|
|
# excluded directories
|
|
|
|
/usr/local/bin/borg create -v --progress --stats -C lzma,3 \\
|
|
|
|
\$REPOSITORY::backup-\`date +%Y-%m-%d-%H%M\` \\
|
|
|
|
/ \\
|
|
|
|
--exclude /run \\
|
|
|
|
--exclude /snapshots \\
|
|
|
|
--exclude /tank \\
|
|
|
|
--exclude /scratch \\
|
|
|
|
--exclude /swap \\
|
|
|
|
--exclude /proc \\
|
|
|
|
--exclude /sys \\
|
|
|
|
--exclude /var/lib/schroot/mount \\
|
|
|
|
--exclude /var/lib/lxcfs \\
|
|
|
|
--exclude /var/lib/docker \\
|
|
|
|
--exclude /mnt
|
|
|
|
|
|
|
|
# Use the 'prune' subcommand to maintain 7 daily, 4 weekly
|
|
|
|
# and 6 monthly archives.
|
|
|
|
/usr/local/bin/borg prune -v --list \$REPOSITORY \\
|
|
|
|
--keep-daily=7 \\
|
|
|
|
--keep-weekly=4 \\
|
|
|
|
--keep-monthly=6
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod a+x /root/borg_backup.sh
|
|
|
|
|
|
|
|
```
|