[ale] rsync --delete and initating backups questions
Charles Brian Quinn
me at seebq.com
Mon Jan 30 00:19:57 EST 2006
Responding to my own post, sorry!
Well, here's one part of my question answered:
Google and I found http://www.mikerubel.org/computers/rsync_snapshots/
which states:
----------
Using the --delete flag
If a file was originally in both source/ and destination/ (from an
earlier rsync, for example), and you delete it from source/, you
probably want it to be deleted from destination/ on the next rsync.
However, the default behavior is to leave the copy at destination/ in
place. Assuming you want rsync to delete any file from destination/ that
is not in source/, you'll need to use the --delete flag:
rsync -a --delete source/ destination/
-------------
--
Charles Brian Quinn
www.seebq.com
Charles Brian Quinn wrote:
> Hi Alers,
>
> Before I set my rsync backup scripts in motion, I just wanted to ask a
> quick question.
>
> I always get nervous when I see a command with the --delete flag,
> especially when it's going to be run on my web-site, and everything dear
> to me.
>
> So, I've setup .ssh keys for the "backup" user on both my colocated
> server, and a server at home (my mythtv server with a dynamic dns
> entry). So I can ssh/scp back and forth without any passwords.
>
> Here is my rsync_backup.sh I'm planning on running:
>
> -------
> #!/bin/bash
> # an rysnc backup script
> # invoked by /etc/cron.daily/rsyncbackupcronjob.sh
>
> ssh="/usr/bin/ssh"
> sshkey="/home/backup/.ssh/id_dsa"
> rsync="/usr/bin/rsync"
> rsync_opts=" --delete --compress --archive "
> sshadd="/usr/bin/ssh-add"
> backup_host="xxxxxx.homelinux.com"
>
> directories_to_backup="/var/www/xxxxxx/htdocs /var/www/xxxxxx /home/xxxxxx"
>
> for dir in $directories_to_backup; do
> # copy a directory to the backup server
> $rsync $rsync_opts -e "$ssh -i $sshkey" $dir
> backup@$backup_host:backups/
> done
> ------------
>
> Now, here's the thing that worries me. These two directories will be
> kept in "sync" right? So does it matter which one initiates? For
> instance, the first time, it would be a lot faster to initiate from the
> home machine (the cable modem has a faster download than upload) -- of
> course I'd have to change around who was copying and from who, but after
> that, can it be setup to be a cron job on the "remote" server, assuming
> the directories are swapped around? Is there a benefit to running it on
> one versus the other?
>
> My other concern stems from the --delete flag. If the dates on those
> servers drift, it would not be wise to initiate (do it the first time)
> from one server, and then run the job on the other, right?
>
> I'll be documenting my final setup and will post to the list when it's up.
>
> Thanks,
More information about the Ale
mailing list