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.
- 10-02-2012 #1Just Joined!
- Join Date
- Aug 2012
- Posts
- 54
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?
- 10-02-2012 #2
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/
- 10-02-2012 #3Just Joined!
- Join Date
- Aug 2012
- Posts
- 54
- 10-02-2012 #4
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/
- 10-02-2012 #5Just Joined!
- Join Date
- Oct 2012
- Posts
- 2
any idea wat copy is for comparing?
- 10-02-2012 #6Just 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?
- 10-02-2012 #7Just 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.
- 10-03-2012 #8Just Joined!
- Join Date
- Aug 2012
- Posts
- 54
- 10-03-2012 #9
Another option is rsync which has the ability to exclude files. Have a look through the man page (man rsync).
If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)
My new blog. It's probably not as good as I think it is.
The Fifth Continent reborn
- 10-03-2012 #10Just Joined!
- Join Date
- Aug 2012
- Posts
- 54


Reply With Quote

