backups:rdiff_backup
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
backups:rdiff_backup [2016/11/10 14:43] – peter | backups:rdiff_backup [2019/11/26 20:30] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Backups - rdiff backup ====== | ||
- | |||
- | <file bash rdiff-backup> | ||
- | #!/bin/bash | ||
- | EXCLUDES="/ | ||
- | OPTIONS=" | ||
- | MAXAGE=" | ||
- | |||
- | SRC="/" | ||
- | DST=" | ||
- | |||
- | for i in $EXCLUDES; do | ||
- | OPTIONS=" | ||
- | done | ||
- | |||
- | rdiff-backup $OPTIONS $SRC $DST | ||
- | STATUS=$? | ||
- | |||
- | msg="" | ||
- | if [ $STATUS -eq 0 ]; then | ||
- | msg=" | ||
- | rdiff-backup --force --remove-older-than $MAXAGE $DST | ||
- | if [ $? -eq 0 ]; then | ||
- | msg=" | ||
- | else | ||
- | msg=" | ||
- | fi | ||
- | else | ||
- | msg=" | ||
- | fi | ||
- | |||
- | echo $msg | ||
- | exit $STATUS | ||
- | </ | ||
- | |||
- | |||
- | ===== Example usage ===== | ||
- | |||
- | We have two systems: host1 and host2. | ||
- | |||
- | * The script to launch the backup has to be on host1, which will connect to host2 by SSH and retrieves data from it. | ||
- | * Both computers must have the rdiff-backup script installed, preferably at the same version. | ||
- | |||
- | On the host1 (the command is performed using the root account): | ||
- | |||
- | We create a key pair to log in via SSH: | ||
- | |||
- | <code bash> | ||
- | ssh-keygen -t rsa | ||
- | </ | ||
- | |||
- | Save files to the default location; when prompted for a password hit enter (a blank password / no password). | ||
- | |||
- | Copy the public key for host2. | ||
- | |||
- | <code bash> | ||
- | scp .ssh / id_rsa.pub host2: | ||
- | </ | ||
- | |||
- | |||
- | On host2 (command is performed using the root account): | ||
- | |||
- | We create (if there is no .ssh directory already) and set it appropriate permissions: | ||
- | |||
- | <code bash> | ||
- | mkdir .ssh | ||
- | chmod 700 .ssh | ||
- | </ | ||
- | |||
- | |||
- | We put the public key of host1 in .ssh/ | ||
- | |||
- | <code bash> | ||
- | cat id_rsa.pub > .ssh/ | ||
- | chmod 600 .ssh/ | ||
- | </ | ||
- | |||
- | Edit the .ssh/ | ||
- | |||
- | <file bash .ssh/ | ||
- | command="/ | ||
- | </ | ||
- | |||
- | Configure SSHD: | ||
- | |||
- | <file bash / | ||
- | PermitRootLogin forced-commands-only | ||
- | StrictMode on | ||
- | </ | ||
- | |||
- | # The later command enforces permissions and .ssh .ssh/ | ||
- | |||
- | Restart SSHD | ||
- | |||
- | <code bash> | ||
- | / | ||
- | </ | ||
- | |||
- | And ready. On the host1, we can do test: | ||
- | |||
- | <code bash> | ||
- | rdiff-backup --print-statistics host2::/etc /tmp/etc2 | ||
- | </ | ||
- | |||
- | This will perform the backup without asking for a password. | ||
backups/rdiff_backup.1478789029.txt.gz · Last modified: 2020/07/15 09:30 (external edit)