Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
en:backup:server [2022/02/25 21:29] – [rsync] added borg link in alert info dan | en:backup:server [2022/02/26 23:07] – added syncthing dan | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Server & desktop backup solutions ====== | ====== Server & desktop backup solutions ====== | ||
+ | The first backups will take a while. The following ones are much faster, but it depends on how much you change. Only the changes are saved. | ||
===== rsync ===== | ===== rsync ===== | ||
Line 9: | Line 10: | ||
<alert type=" | <alert type=" | ||
+ | |||
+ | ==== Dependencies ==== | ||
+ | |||
+ | The script needs '' | ||
+ | |||
+ | < | ||
+ | pacman -S inetutils | ||
+ | </ | ||
+ | |||
==== Credentials ==== | ==== Credentials ==== | ||
Line 17: | Line 27: | ||
</ | </ | ||
- | + | ==== Script | |
- | === Server | + | |
- | + | ||
- | + | ||
- | == Script | + | |
Add your details for '' | Add your details for '' | ||
+ | < | ||
+ | nano / | ||
+ | </ | ||
< | < | ||
#!/bin/sh | #!/bin/sh | ||
Line 40: | Line 49: | ||
DAEMONUSER="" | DAEMONUSER="" | ||
DAEMONHOST="" | DAEMONHOST="" | ||
+ | HOSTNAME=$(hostname) | ||
MINCHANGES=1 | MINCHANGES=1 | ||
Line 68: | Line 78: | ||
fi | fi | ||
- | + | rsync -avAXHP --delete --password-file=/ | |
- | rsync -avAXHP --delete --password-file=/ | + | </ |
+ | < | ||
+ | chmod +x /root/ | ||
</ | </ | ||
- | == Exclude folder and files == | + | === Exclude folder and files === |
- | This is an example | + | This is an example. Add anything you don't need to backup. And change home '' |
< | < | ||
- | backup-filter.rule | + | nano /root/backup-filter.rule |
</ | </ | ||
< | < | ||
Line 88: | Line 100: | ||
/mnt/* | /mnt/* | ||
/media/* | /media/* | ||
- | /home/* | ||
- | / | ||
/lost+found | /lost+found | ||
+ | # root user | ||
+ | / | ||
+ | / | ||
+ | # Home user | ||
+ | / | ||
</ | </ | ||
- | === Desktop (home) === | ||
+ | ===== borg ===== | ||
- | == Script == | + | <alert type=" |
- | Add your details for '' | + | Follow our [[en: |
- | < | + | The snapshots are stored remotely via ssh. |
- | #!/bin/sh | + | |
- | ## Based on: | ||
- | ## my own rsync-based snapshot-style backup procedure | ||
- | ## (cc) marcio rps AT gmail.com | ||
- | # config vars | + | ===== Crontab - rsync and borg ===== |
- | real_user=$SUDO_USER | + | Follow our [[en: |
- | SRC="/home/$real_user/" | + | < |
- | SNAP="/home/ | + | @daily |
- | OPTS=" | + | </code> |
- | EXCL=" | + | < |
- | DAEMONUSER="" | + | @daily |
- | DAEMONHOST="" | + | </ |
- | MINCHANGES=1 | + | |
- | # run this process with real low priority | + | * '' |
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
- | ionice -c 3 -p $$ | ||
- | renice +12 -p $$ | ||
- | # sync | + | ===== Syncthing ===== |
- | rsync $OPTS $EXCL $SRC $SNAP/ | + | Follow our [[en: |
- | # check if enough has changed and if so | ||
- | # make a hardlinked copy named as the date | ||
- | COUNT=$( wc -l $SNAP/ | + | ==== Add device ==== |
- | if [ $COUNT -gt $MINCHANGES ] ; then | + | |
- | DATETAG=$(date +%Y-%m-%d-%H: | + | |
- | if [ ! -e $SNAP/ | + | |
- | cp -al $SNAP/ | + | |
- | chmod u+w $SNAP/ | + | |
- | mv $SNAP/ | + | |
- | chmod u-w $SNAP/ | + | |
- | fi | + | |
- | fi | + | |
+ | Add the backup server to your client under '' | ||
- | rsync -avAXHP --delete --password-file=/ | ||
- | </ | ||
+ | ==== Add folder ==== | ||
- | == Exclude | + | * Add a folder |
+ | * Select your backup server under '' | ||
+ | * Under '' | ||
+ | * Also check '' | ||
- | This is an example. Add anything you don't need to backup. | ||
- | < | + | |
- | backup-filter.rule | + | |
- | </ | + | |
- | < | + | |
- | backup/ | + | |
- | .cache/ | + | |
- | </ | + |