Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 18 of 18
Hi. Your just need to install the RSYNC package, like sudo apt-get install rsync. Then the copy function is quite trivial, like rsync -av source_dir dest_dir. rsync will handle the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Newbie
    Join Date
    Aug 2006
    Posts
    124

    Hi. Your just need to install the RSYNC package, like sudo apt-get install rsync.
    Then the copy function is quite trivial, like rsync -av source_dir dest_dir.
    rsync will handle the updates and so on, and will not copy the already existing files. You also won"t have problems with rights on files, like you could have with CP if using the wrong switches.

  2. #12
    Just Joined!
    Join Date
    Jun 2012
    Posts
    11
    I wouldn't necessarily recommend doing this because it seems inefficient and I think there could possibly be some issues trying to copy stuff from /proc and there are a lot of symbolic links in some of the sub directories in /lib and you would essentially double the space used in the root partition so you need to make sure you even have room before you try to copy everything, but if you had to:

    Code:
    ls -a / | grep -v root | xargs -i cp -r /{} /root/backups
    ls -a /root | grep -v backups | xargs -i cp -r /root/{} /root/backups
    you would basically be taking all the root directories, excluding /root and then copying over into root/backups. Then since you did not copy /root into /root/backups you would run the second command to copy everything from /root except for the backups directory into /root/backups.

    I think elija's option for rsync might be better, but I am not as familiar with how rsyc works as I wold like.

  3. #13
    Just Joined!
    Join Date
    Aug 2012
    Posts
    54
    Quote Originally Posted by jedlickaj View Post
    I wouldn't necessarily recommend doing this because it seems inefficient and I think there could possibly be some issues trying to copy stuff from /proc and there are a lot of symbolic links in some of the sub directories in /lib and you would essentially double the space used in the root partition so you need to make sure you even have room before you try to copy everything, but if you had to:

    Code:
    ls -a / | grep -v root | xargs -i cp -r /{} /root/backups
    ls -a /root | grep -v backups | xargs -i cp -r /root/{} /root/backups
    you would basically be taking all the root directories, excluding /root and then copying over into root/backups. Then since you did not copy /root into /root/backups you would run the second command to copy everything from /root except for the backups directory into /root/backups.

    I think elija's option for rsync might be better, but I am not as familiar with how rsyc works as I wold like.
    I like this idea and i have been trying it as
    ls -a / | grep -v root | xargs -i cp -rf /{} /root/backup

    But i keep getting same "cannot open SOMEPATH for reading: Permission denied" errors during the process even though i am using this command through SSH and using root user. So there shouldnt be any error.

    Any ideas about how to fix this permission problem and make it copy EVERYTHING ?

  4. $spacer_open
    $spacer_close
  5. #14
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by Website View Post
    I like this idea and i have been trying it as
    ls -a / | grep -v root | xargs -i cp -rf /{} /root/backup

    But i keep getting same "cannot open SOMEPATH for reading: Permission denied" errors during the process even though i am using this command through SSH and using root user. So there shouldnt be any error.

    Any ideas about how to fix this permission problem and make it copy EVERYTHING ?
    can you show the exact error message showing the files on which you are getting permission errors? I am guessing it is pipes or special device files in the /dev directory or something.

    also, you don't need to copy the /proc, /dev and /sys folders, as they are created by the kernel at boot time. well, sometimes /dev is not created, it depends.

    you also don't want to copy "." and "..", so exclude those.

    this is easier to do with a find command, so for example:
    Code:
    find / -mindepth 1 -maxdepth 1 -not -name 'dev' -not -name 'root' -not -name 'proc' -not -name 'sys'|xargs -i cp -rf {} /root/backup
    if you want to see what it will do before actually running it, just insert an echo before the cp, e.g.:

    Code:
    xargs -i echo cp
    HOWEVER, I would use rsync for this myself.

  6. #15
    Just Joined!
    Join Date
    Aug 2012
    Posts
    54
    also, you don't need to copy the /proc, /dev and /sys folders, as they are created by the kernel at boot time. well, sometimes /dev is not created, it depends.
    Yep. This was the issue.

    Will use this next time.
    find / -mindepth 1 -maxdepth 1 -not -name 'dev' -not -name 'root' -not -name 'proc' -not -name 'sys'|xargs -i cp -rf {} /root/backup
    Thank you.

    Here is what happened, I think copy goes in loop and gets stuck after a while because so far i saw a file created in root/backup/backup/usr/......
    I think it would be better to exclude root/backup instead of entire root. Because i will need the root folder later on anyways. Also it would be nice to watch the output of the process.

    Also i just noticed that it creates /backup folder in / too.

    Can you also give me the command to cp -u so i can just put that in cron job to update the files everyday?
    Last edited by Website; 10-04-2012 at 06:16 AM.

  7. #16
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by Website View Post
    Here is what happened, I think copy goes in loop and gets stuck after a while because so far i saw a file created in root/backup/backup/usr/......
    I think it would be better to exclude root/backup instead of entire root. Because i will need the root folder later on anyways. Also it would be nice to watch the output of the process.

    Also i just noticed that it creates /backup folder in / too.
    why don't you show us what is in your / dir, maybe that will clear things up.

    Can you also give me the command to cp -u so i can just put that in cron job to update the files everyday?
    okay, if this is going to be a daily thing, i am going to insist that you use rsync! this is what rsync was made for. it is extremely flexible and scriptable and will ultimately be faster and better for you. it will be able to handle symlinks and will take a list of files (or regexs, wildcards, etc.) to ignore.

    The ever verbose Arch Linux folks have a good article on backing up an entire root filesystem using rsync - check it out:

    https://wiki.archlinux.org/index.php...kup_with_rsync

  8. #17
    Just Joined!
    Join Date
    Aug 2012
    Posts
    54
    I installed rsync in my webmin but it says
    Rsync Daemon:
    ..checking : not running

    So i tried to create a config file but its pretty hard to configure all those things and set the rsync up. Plus i dont think there is a GUI for it either. Well if im gonna put commands and deal with ssh, then i can just put one update command everyday (once the copy is done) and thas all.

  9. #18
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,649
    I wouldn't worry about it not running as a daemon. Just run it as a command and put that in your cron as you would with the cp command.

    [edit]an rsync tutorial[/code]
    "I used to be with it, then they changed what it was.
    Now what was it isn't it, and what is it is weird and scary to me.
    It'll happen to you too."

    Grandpa Simpson



    The Fifth Continent

Page 2 of 2 FirstFirst 1 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •