[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1018
  • Last Modified:

How to specify root directory with rsync

On a Linux Ubuntu box
I am attempted to tell rsync to back up all data on my hard drive but I keep getting errors.


If I specify root as /
I get error "skipping directory"

I have an external usb hd connected, all I want is to get rsync to back up every file on my hard drive to that external hard drive.

0
jkockler
Asked:
jkockler
  • 7
  • 6
  • 4
5 Solutions
 
fosiul01Commented:
is your hd mounted properly ??

can i see the script ??
0
 
fosiul01Commented:
if you want to take backup

/var, /root, /etc directory,
you sould define those seperately [ some one said you can have all directory in one like /var /etc /root, but i never tryed that, ] but bottom line is you should speicify seperatly]

you will have to say something like this [ its just the sample script ]

rsync -e ssh -avz --delete root@beaver:/var/ $DESTROOT/Directory_name
rsync -e ssh -avz --delete root@beaver:/etc/ $DESTROOT/Directory_name
rsync -e ssh -avz --delete root@beaver:/root/ $DESTROOT/Directory_name
0
 
Maciej SsysadminCommented:
Assuming, you have your external hard drive successfully mounted in /mnt/external

rsync --partial -avz --exclude 'mnt/external' / /mnt/external

or, if your internal harddrive has just one partition (/), you may use:
rsync --partial -avz -x / /mnt/external
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
jkocklerAuthor Commented:
how do I know if it is mounted successfully in /mnt/external? .. It shows up in file browser as a drive and if I go into it, the path shows /media/disk

Why do I have to back up each folder individually?  That does not seem right.

0
 
Maciej SsysadminCommented:
If you see files (or if this is empty disk, you are able to create something - directory, or file), then it means, it is successfully mounted :) You may also run "mount" command to check if this drive is mounted or not.
As I wrote in previous comment - try one of these commands I wrote (if you have just one - root - partition, then run the second command, if you have more than one partition (/usr, /var, /tmp, whatever), then run first one).
You may also add -n option to rsync, which means - display what would be done, without actually doing this (which can be good for testing purposes):
rsync -n --partial ....
Of course you have to change /mnt/external to /media/disk or whatever path you are using to mount this drive.
0
 
jkocklerAuthor Commented:
Ok, but I do not see a source specified in those commands.  I am assuming that it will copy the directory I run the command from?  How do I get to the absolute top of the tree?
0
 
fosiul01Commented:
if you have /var, /etc and otehr directory, then i dont think just only put

/ will copy , you need to specify either

/var /etc  /root in one line

or in different line as i said in my post

also, how to check if its mounted as oklit said,

do mount command it will show you.

also, if you can write any  file in the mounted direcotry that mean its mounted properly
0
 
fosiul01Commented:
which way are you trying ??

0
 
Maciej SsysadminCommented:
There is source specified :)
At the end there is: / /mnt/external. First / is source, then /mnt/external is destination.
0
 
jkocklerAuthor Commented:
nice ... it's running now... As it started, It said "sending incremental file list" ?? ... Does that man If I send the same command to the same place later on, will it only send the data that has been modified since the last backup?

I am going to post another thread here shortly on directory structure.
0
 
Maciej SsysadminCommented:
rsync will go recursively because of -a option specified (-a is synonym for -rlptgoD options, and -r means recursive).
That's why I used --exclude 'mnt/external' option in first command (to not rsync destination directory to itself).
If you want to behave in such way, that it copies everything from one partition only, then you need to specify -x option, which means (from man rsync): don't cross filesystem boundaries.
0
 
jkocklerAuthor Commented:
Also, is that second command grabbing the boot and mbr files too?  
0
 
Maciej SsysadminCommented:
No, it won't touch mbr at all. rsync is for directories/files only.
0
 
jkocklerAuthor Commented:
you said to to use the 'exclude' only if my internal has 2 partitions... Why would it not rsync itself with only one partition on the internal?  The external still shows up as a directory under media which is under the root, right?
0
 
Maciej SsysadminCommented:
Yes, but in second command I used -x option, which means "don't cross filesystem boundaries", so rsync will go recursively under / directory, but /media/disk is another device - separate filesystem, so rsync will omit this.

And I wrote - use it, if you have just _one_ partition (/), not two of them :) (unless second is swap :) - then ok, you can have two partitions in such case :)).
0
 
jkocklerAuthor Commented:
Very good sir..  Is there a command to exclude the trash?
0
 
Maciej SsysadminCommented:
You just have to specify second exclude option:
rsync .... --exclude 'media/disk' --exclude 'Trash' ...
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 7
  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now