rsync backup

Tyler Aviss tjaviss-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Wed Dec 8 22:27:34 UTC 2010


On Tue, Dec 7, 2010 at 9:38 PM, Jason Nicolaides <voidpointer-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
> On 7 December 2010 23:09, William Muriithi <william.muriithi-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org>
> wrote:
>>
>> >
>> > On Tue, Dec 7, 2010 at 3:02 PM, teddy mills <teddymills-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org>
>> > wrote:
>> >>
>> >> I rsync from /home/teddy/ to an external USB hard disk. It works fine.
>> >>
>> >> rsync -avz --delete --exclude-from '/home/teddy/rsync-exclude'
>> >> /home/teddy
>> >> /media/backup
>>
>> The --delete flag is really dangerous.  If it was not for the -v flag,
>> you would have lost all your data.
>
> 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.
>
> 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
>
>

Same applies to SCP, if you put in a trailing slash, it copies the
contents of the last directory rather than the directory itself...

-- 
Tyler Aviss
Systems Support
LPIC/LPIC-2/DCTS/CLA

“It can takes months to gain a customer, but only seconds to lose one"
--
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