rsync backup

William Muriithi william.muriithi-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Wed Dec 8 14:59:08 UTC 2010


>
> The --delete flag is not that dangerous and in this case it was doing
> exactly what it was told to do.  There is an undocumented feature, if you
> will, of rsync for the source and destination paths having a trailing slash
> or not.  For the destination path, the presence or not of a trailing slash
> is completely ignored and does not affect rsync in any way.  It's on the
> source that matters.  If the source doesn't have the trailing slash, the
> directory is copied along with it's contents to the destination.  For
> example, if your source is /home/jason and your destination is /mnt/backups
> then after running rsync you will have /mnt/backups/jason.
Agree with what you said. In the above case, he would never have lost his data

What I meant is the delete flag can leave you with a white face if you
reverse the destination with the source folders.  That would leave you
with zero data in both folders.

I know it sound very unlikely, but it did happen to me and I felt like
the biggest moron in the world after realising what I had just done.
Thats why I adopted the use of -n flag just to see what is taking
place fast.  Actually, in the above case, it would have removed all
that was in the destination folder and if he had stuffed other data
from a different source, that would have been lost as they do not
exist in the source directory

In short, a dry run does not hurt when doing it manually.

William

>
> If you run rsync with a trailing slash on the source path, however, then
> rsync will copy only the contents of the source directory to the
> destination.  So in our above example, the contents of /home/jason would be
> copied to /mnt/backups.
>
> The reason rsync started deleting everything is because you told it to copy
> the contents of /home/teddy to /media/backup.  Since previous rsyncs have
> been without a trailing slash on /home/teddy, what you have on your external
> disks is /media/backup/teddy like William Park said earlier in the thread.
> When you added the trailing slash on /home/teddy/, rsync looked at
> /media/backup, saw that there was no teddy folder in your source, and
> deleted it from the destination.  If you had let rsync complete it would
> have recopied the contents of /home/teddy back onto the external drive, into
> the /media/backup folder, without the teddy subfolder.  Basically a move.
>
> It's kind of funny, I was just writing a bash script today at work to backup
> a subversion repository, and have been reading up on rsync.  Check out
> http://www.mikerubel.org/computers/rsync_snapshots/ for some interesting
> ways of using rsync for hourly/daily/weekly/etc. backups.
>
>
> Oh, this is my first post to the list.  Hi!
>
>
> Cheers,
> Jason Chris Nicolaides
>
>
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list