Looking for someone who knows bash scripting, rsync and rdiff

w1z4rd

Karmic Sangoma
Joined
Jan 17, 2005
Messages
52,146
Reaction score
8,340
Location
127.0.0.1
Im trying to backup a server that has a bad internet connection. I have an rsync script that allows me to reconnect if its an rsync.

Code:
#!/bin/bash

while [ 1 ]
do
    rsync -avz --partial [email protected]:/var/flexshare/shares/ /backup/backup/
    if [ "$?" = "0" ] ; then
        echo "rsync completed normally"
        exit
    else
        echo "Rsync failure. Backing off and retrying..."
        sleep 180
    fi
done

How would I add my rdiff command to that?

Code:
/usr/bin/rdiff-backup server1_backup:/remote_backup_folder/ /local_backup_folder
 
Last edited:
I might be missing something here, given it is late and im long overdue on sleep, but isnt your rsync command doing what you want your rdiff command to be doing?

As I recall, rdiff is based on rsync. Anyhow, if the intent is to replace rsync in the script with rdiff, then its not difficult at all. Just replace the rsync line with you rdiff line. Leave the rest of the script the same. And obviously, you'll need to change the arguments to the rdiff command to reflect the actual server, remote location and local location, etc.
 
I might be missing something here, given it is late and im long overdue on sleep, but isnt your rsync command doing what you want your rdiff command to be doing?

As I recall, rdiff is based on rsync. Anyhow, if the intent is to replace rsync in the script with rdiff, then its not difficult at all. Just replace the rsync line with you rdiff line. Leave the rest of the script the same. And obviously, you'll need to change the arguments to the rdiff command to reflect the actual server, remote location and local location, etc.

Need incremental backups.
 
We went down this same path. It's not an answer to your question, but have a look at http://backuppc.sourceforge.net/
It's an opensource cross platform backup solution, that will do full and incremental backup sets of a machine. The nice part is the web frontend, easy config and proper scheduling (yearly, monthly, weekly, daily).

It has a pretty cool feature where it pools files with the same file hash to save space.
We used to script our own backups, but it became a hassle over a lot of servers.
 
Hmmm... ok well while no rdiff-backup expert myself, I know it does a general mirror copy using differentials, but keeps version history as well. Which could be what you are trying to achieve, if you have to use rdiff-backup...

If it is, then you generally use the simple rdiff-backup command to create the backup, in a similar manner as to how rsync performs. The backup is a mirror copy, and is made in a similar way to how rsync creates its backups. But then to restore a backup from a particular date, have a look here , at bullet point 3 under the "Restoring" sub section. Noteably in this particular example point, the file or directory is restored to a temp folder, not the local working folder that was being backed up.

Anyhow, thats what I have... I don't think it fully answers your question, but thats about what I know about rdiff-backup...
 
Use BackInTime it is a simple framework for rsync, diff and cron. I have used it for more than a month now on my system.

PS. Don't back up to a ntfs filesystem it doesn't support hard-links for incremental backups.
 
You can try adding the rdiff command directly after the rsync one separated with && - this will cause the rdiff command to run _if_ the rsync one was successful and skip it if it wasn't, allowing the script to continue as intended.

edit: to clarify, you can separate commands with && and ;

&& will run the next command if the previous one exited with 0 (success) and ; will run commands in order regardless of their exit status.
 
Top
Sign up to the MyBroadband newsletter
X