Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18
I want to add a cron job to copy the entire server files (whatever i see in ftp) to a folder in the same server but then the next day, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2012
    Posts
    54

    Question Command to copy and update files from a folder to another folder


    I want to add a cron job to copy the entire server files (whatever i see in ftp) to a folder in the same server but then the next day, just update the files which was updated since the last time.

    So its not gonna copy all the files everyday but its gonna check the "last edited day" and update the copy based on that. So it will take lot less time than getting an entire copy of the same server again.

    Can somebody help me about this please?

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,847
    Check the man page for cp. You can use the -u (--update) flag to copy only newer files to the destination. I think this will do what you're asking for.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Just Joined!
    Join Date
    Aug 2012
    Posts
    54
    Quote Originally Posted by Roxoff View Post
    Check the man page for cp. You can use the -u (--update) flag to copy only newer files to the destination. I think this will do what you're asking for.
    Thank you. So if you mean i should copy the entire server to the folder for the first time and then just cron job the "Update" command, it will be ok?

    Can you give me an example of an update command? from one folder to another?

  4. #4
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,847
    Yes, it will be OK.

    It's a standard copy. Use 'cp -u [source] [dest]', as the man page tells you in the link I posted.
    Linux user #126863 - see http://linuxcounter.net/

  5. #5
    Just Joined!
    Join Date
    Oct 2012
    Posts
    2
    any idea wat copy is for comparing?

  6. #6
    Just Joined!
    Join Date
    Aug 2012
    Posts
    54
    well for me to use the -u i need to copy the entire / in the /backups folder and when enter below code i get the below error
    [root@merkez ~]# cp / /root/backups
    cp: omitting directory `/'


    What should i do?

  7. #7
    Just Joined!
    Join Date
    Jun 2012
    Posts
    11
    It is omitting the / because it is a directory. To copy a directory you need the -r option so that it copies everything recursively.


    I cannot test the command because I do not have a computer I can use right now to copy the entire root directory somewhere, however, I think your command might also cause a loop since /root/backups is part of the / directory structure. That means you will be trying to copy /root/backups into /root/backups which will cause you a problem.
    Last edited by jedlickaj; 10-02-2012 at 05:03 PM.

  8. #8
    Just Joined!
    Join Date
    Aug 2012
    Posts
    54
    Quote Originally Posted by jedlickaj View Post
    It is omitting the / because it is a directory. To copy a directory you need the -r option so that it copies everything recursively.


    I cannot test the command because I do not have a computer I can use right now to copy the entire root directory somewhere, however, I think your command might also cause a loop since /root/backups is part of the / directory structure. That means you will be trying to copy /root/backups into /root/backups which will cause you a problem.
    So what can i do?
    How can i copy all the files to /root/backups ?

  9. #9
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,485
    Another option is rsync which has the ability to exclude files. Have a look through the man page (man rsync).
    What do we want?
    Time machines!

    When do we want 'em?
    Doesn't really matter does it!?


    Conkybots: Interactive plugins for your Conkys!

  10. #10
    Just Joined!
    Join Date
    Aug 2012
    Posts
    54
    Quote Originally Posted by elija View Post
    Another option is rsync which has the ability to exclude files. Have a look through the man page (man rsync).
    Which one i should install
    rsyncmin 1.146-54
    or
    Syncmin 1.0

    and what is the difference anyways?

Page 1 of 2 1 2 LastLast

Posting Permissions

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