Use RSYNC to copy changes in sda to sdb -- [*SOLVED*]

You have a problem with Salix? Post here and we'll do what we can to help.
User avatar
thenktor
Salix Wizard
Posts: 2426
Joined: 6. Jun 2009, 14:47
Location: Franconia
Contact:

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]

Post by thenktor »

And of course you have to exclude /media, too ;)
Image
burnCDDA (burns audio CDs)
geBIERt (German beer blog)
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]

Post by Dennola4 »

Oh yeah, good point.

Code: Select all

rsync -avx --exclude=/dev --exclude=/proc --exclude=/media / /media/disk
Thanks!

:)
Last edited by Dennola4 on 15. Sep 2010, 02:58, edited 2 times in total.
There are no stupid questions.
User avatar
JRD
Salix Warrior
Posts: 950
Joined: 7. Jun 2009, 22:52
Location: Lyon, France

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]

Post by JRD »

As an addition to this thread, I can also advice the use of the alternate software: backintime
As also an alternate method, why not using software RAID in mirror?
Image
User avatar
thenktor
Salix Wizard
Posts: 2426
Joined: 6. Jun 2009, 14:47
Location: Franconia
Contact:

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]

Post by thenktor »

JRD wrote:why not using software RAID in mirror?
Because RAID is not a backup ;) If I accidentally delete some files they are gone on my RAID but not on a backup.
Image
burnCDDA (burns audio CDs)
geBIERt (German beer blog)
User avatar
JRD
Salix Warrior
Posts: 950
Joined: 7. Jun 2009, 22:52
Location: Lyon, France

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]

Post by JRD »

you're right. I just don't know the reason of the poster whereas he searched for a backup solution or a redondance solution.
Image
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]

Post by Dennola4 »

I looked at backintime, but since Slackware already comes with rsync, and since rsync is capable of doing what I need, the only obstacle would be my own ignorance. Therefore, time to learn rsync. :-)

I actually have two more questions. Sorry, but I really want to understand what I'm doing rather than just copying and pasting code.

1) I notice that in the rsync line you offered....

Code: Select all

rsync -avx --exclude=/dev --exclude=/proc / /media/disk
..../media/disk doesn't end with a trailing backslash, like this: /media/disk/ and I am wondering why not.

2) As you know, /home/dennis is on a separate partition. So when I mirror that sda partition to the corresponding sdb partition , do I use the same type of rsync line? In other words, would I run:

Code: Select all

rsync -avx /home/dennis /media/disk-1/dennis
....OR:

Code: Select all

rsync -avx /home/dennis/ /media/disk-1/dennis/
...OR none of the above?? Thanks for your patience in answering these questions.

:?: :?: :?:
Last edited by Dennola4 on 15. Sep 2010, 03:00, edited 2 times in total.
There are no stupid questions.
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]

Post by Shador »

It doesn't matter, unless for some very poorly written programs scripts maybe. But then they usually do something like this "/some/path" + "file" = "/some/pathfile" instead of doing "/some/path" + "/file".
In the first form /some/path may be a directory or a file.
In the second form /some/path/ must be a file.
Try this (best run it in a separate, empty directory):

Code: Select all

set -x
echo "blob" > blub
cat blub
cat blub/
rm blub
mkdir blub
touch blub/dennola
ln -s blub blob
ls -l blob
ls -l blob/
ls -l ./blob/../blub/..////blob
rm blob
rm -r blub
set +x
So for directories it doesn't matter whether there's a leading slash or not but for files it does and for symlinks/soft links too.
I can even build crazy paths like that last ls command and can use as many slashes as I want.
Image
User avatar
thenktor
Salix Wizard
Posts: 2426
Joined: 6. Jun 2009, 14:47
Location: Franconia
Contact:

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]

Post by thenktor »

Shador: I have to correct you here :) For rsync the trailing slashes are very important on the source dir.

rsync -av /home /backup creates a folder home inside of /backup.
rsync -av /home/ /backup syncs the content of home directly to /backup.

These 2 commands do the same:
rsync -av /src/foo /dest
rsync -av /src/foo/ /dest/foo

EDIT:
rsync -avx /home/dennis /media/disk-1/dennis would result in a dir structure /media/disk-1/dennis/dennis
rsync -avx /home/dennis/ /media/disk-1/dennis/ is OK. The trailing slash on the destination directory is not needed but does not harm.
Image
burnCDDA (burns audio CDs)
geBIERt (German beer blog)
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]

Post by Dennola4 »

Ok thenktor. I think I've got it.

There's still one thing hurting my brain. In the command:

Code: Select all

rsync -avx --exclude=/dev --exclude=/proc --exclude=/media / /media/disk
the source actually IS a leading slash (being the character representation of the root directory). So are we to just understand that a trailing slash is implied?

I hope I don't seem obtuse, I just can't seem to get rsync syntax clear in my mind and I would rather not bork my back-up HDD because I was too timid to ask specific questions..

Thanks again.

:idea:
Last edited by Dennola4 on 15. Sep 2010, 03:06, edited 3 times in total.
There are no stupid questions.
User avatar
thenktor
Salix Wizard
Posts: 2426
Joined: 6. Jun 2009, 14:47
Location: Franconia
Contact:

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]

Post by thenktor »

It's a leading and a trailing slash :)
Image
burnCDDA (burns audio CDs)
geBIERt (German beer blog)
Post Reply