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 07:34] – [Server & desktop backup solutions] Added information about how long a backup will take. dan | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Server & desktop backup solutions ====== | ====== Server & desktop backup solutions ====== | ||
+ | The first backup of the two options takes 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 9: | ||
<alert type=" | <alert type=" | ||
+ | |||
+ | ==== Dependencies ==== | ||
+ | |||
+ | The script needs '' | ||
+ | |||
+ | < | ||
+ | pacman -S inetutils | ||
+ | </ | ||
+ | |||
==== Credentials ==== | ==== Credentials ==== | ||
Line 17: | Line 26: | ||
</ | </ | ||
- | + | ==== Script | |
- | === Server | + | |
- | + | ||
- | + | ||
- | == Script | + | |
Add your details for '' | Add your details for '' | ||
+ | < | ||
+ | nano / | ||
+ | </ | ||
< | < | ||
#!/bin/sh | #!/bin/sh | ||
Line 40: | Line 48: | ||
DAEMONUSER="" | DAEMONUSER="" | ||
DAEMONHOST="" | DAEMONHOST="" | ||
+ | HOSTNAME=$(hostname) | ||
MINCHANGES=1 | MINCHANGES=1 | ||
Line 68: | Line 77: | ||
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 99: | ||
/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 ===== |
- | real_user=$SUDO_USER | + | Follow our [[en: |
- | SRC="/ | + | <code> |
- | SNAP="/ | + | @daily |
- | OPTS=" | + | |
- | EXCL=" | + | |
- | DAEMONUSER="" | + | |
- | DAEMONHOST="" | + | |
- | MINCHANGES=1 | + | |
- | + | ||
- | # run this process with real low priority | + | |
- | + | ||
- | ionice -c 3 -p $$ | + | |
- | renice +12 -p $$ | + | |
- | + | ||
- | # sync | + | |
- | + | ||
- | rsync $OPTS $EXCL $SRC $SNAP/ | + | |
- | + | ||
- | # check if enough has changed and if so | + | |
- | # make a hardlinked copy named as the date | + | |
- | + | ||
- | COUNT=$( wc -l $SNAP/rsync.log|cut -d" " -f1 ) | + | |
- | if [ $COUNT -gt $MINCHANGES ] ; then | + | |
- | DATETAG=$(date +%Y-%m-%d-%H: | + | |
- | if [ ! -e $SNAP/$DATETAG ] ; then | + | |
- | cp -al $SNAP/ | + | |
- | chmod u+w $SNAP/ | + | |
- | mv $SNAP/rsync.log $SNAP/ | + | |
- | chmod u-w $SNAP/ | + | |
- | fi | + | |
- | fi | + | |
- | + | ||
- | + | ||
- | rsync -avAXHP --delete --password-file=/ | + | |
</ | </ | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
- | == Exclude folder and files == | ||
- | |||
- | This is an example. Add anything you don't need to backup. | ||
- | |||
- | < | ||
- | backup-filter.rule | ||
- | </ | ||
- | < | ||
- | backup/ | ||
- | .cache/ | ||
- | </ |