Hello, I have two directories that are almost identical to each other and I need to copy the contents of the source directory over the to the target directory, but without overwriting any files that are newer on the target. Is there an argument that I can use with the 'cp' command to accomplish this? I have the following to preserve time stamps and permissions; cp -pRv /mnt/userdir /media/userdir Thank you, James -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 03 May 2007 22:58, James D. Parra wrote:
Is there an argument that I can use with the 'cp' command to accomplish this? I have not used cp for this... but you might try tar.
The -u switch of tar will only append files to an existing tarball that are newer than the copy in the existing archive. So, you tar up the first directory... and then tar the second directory (appending to the first archive) using the -u switch... and then extract the entire archive to a new directory. -- Kind regards, M Harris <>< -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 03 May 2007 23:25, M Harris wrote:
I have not used cp for this... but you might try tar.
The -u switch of tar will only append files to an existing tarball that are newer than the copy in the existing archive. Actually... see man cp... the cp command also has an -u switch for update which will do what you want...
-- Kind regards, M Harris <>< -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 03 May 2007 21:30, M Harris wrote:
On Thursday 03 May 2007 23:25, M Harris wrote:
I have not used cp for this... but you might try tar.
The -u switch of tar will only append files to an existing tarball that are newer than the copy in the existing archive.
Actually... see man cp... the cp command also has an -u switch for update which will do what you want...
True, and I use it often. You should know that only the modification time (or the absence of a source file in the destination directory) is used to determine whether or not to copy a file. A more refined selective copy can be accomplished using the rsync command (which operates fine locally despite the 'r' for "remote" in its name). Rsync is not the easiest program to master, but it's very powerful.
... M Harris <><
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 03 May 2007 23:33, Randall R Schulz wrote:
You should know that only the modification time (or the absence of a source file in the destination directory) is used to determine whether or not to copy a file. So, no content checking...
A more refined selective copy can be accomplished using the rsync command (which operates fine locally despite the 'r' for "remote" in its name). Rsync is not the easiest program to master, but it's very powerful. Can the rsync be used from cron tabs to create a file mirroring system between several machines?
-- Kind regards, M Harris <>< -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 03 May 2007 22:02, M Harris wrote:
On Thursday 03 May 2007 23:33, Randall R Schulz wrote:
You should know that only the modification time (or the absence of a source file in the destination directory) is used to determine whether or not to copy a file.
So, no content checking...
Nope.
A more refined selective copy can be accomplished using the rsync command (which operates fine locally despite the 'r' for "remote" in its name). Rsync is not the easiest program to master, but it's very powerful.
Can the rsync be used from cron tabs to create a file mirroring system between several machines?
Certainly. There's already a package (available in SuSE 10.0 and, I presume, in openSUSE) called rdiff-backup which does this. See http://www.nongnu.org/rdiff-backup/.
... M Harris <><
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Friday 04 May 2007 00:36, Randall R Schulz wrote:
Certainly. There's already a package (available in SuSE 10.0 and, I presume, in openSUSE) called rdiff-backup which does this. See http://www.nongnu.org/rdiff-backup/. ~cool... thanks! :)
-- Kind regards, M Harris <>< -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Thursday 2007-05-03 at 22:36 -0700, Randall R Schulz wrote:
Can the rsync be used from cron tabs to create a file mirroring system between several machines?
Certainly. There's already a package (available in SuSE 10.0 and, I presume, in openSUSE) called rdiff-backup which does this. See http://www.nongnu.org/rdiff-backup/.
Two packages: there is also rsnapshot: # Summary : backup programm using hardlinks # Description : # rsnapshot is a filesystem snapshot utility for making backups of # local and remote systems. Using rsync and hard links, it is possible # to keep multiple, full backups instantly available. The disk space # required is just a little more than the space of one full backup, # plus incrementals. Depending on your configuration, it is quite # possible to set up in just a few minutes. Files can be restored by # the users who own them, without the root user getting involved. There # are no tapes to change, so once it's set up, you may never need to # think about it again. Right now, I don't know the difference between rsnapshot and rdiff-backup - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFGOu/dtTMYHG2NR9URAsiEAJ9WwWiZp9aGf6ahUG3eEAj0W6JLMwCePPmX gDwmUu81KBJ/v4ocD5oTosQ= =zQVO -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Rsync is not the easiest program to master, but it's very powerful.
- using CRON to do regular system back-ups to a separate partition, can be handy . . . something like :- ..................... #!/bin/sh # # use rsync to backup / to /dev/hdb5 # mount -t ext3 /dev/hdb5 /mnt_cron # df cd rsync -avr --delete --delete-after --exclude=/media --exclude=/mnt --exclude=/mnt_cron --exclude=/proc --exclude=subdomain --exclude=/sys --exclude=/tmp / /mnt_cron cd # adjust fstab root-mount-point cp /mnt_cron/etc/fstab.5Bbak /mnt_cron/etc/fstab df umount /mnt_cron ............................ have a Good Day -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Fri 04 May 2007 04:25, M Harris wrote:
I have not used cp for this... but you might try tar.
- for Cloning a system . . . for Copying a Directory, TAR is true & tried :- tar clf - . | ( umask 0; cd /mnt; tar xvf - ) [ where /mnt is where you wish to send the stuff ] .................... have a Good Day -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
cp -u sourceFile targetFile u can update only the latest file see man cp first (it also work for other command) :D for more strict u can "set -o noclobber" on cli if u don't wanna overwrite the existing file with older o newest file for more info http://www.cyberciti.biz/tips/howto-keep-file-safe-from-overwriting.html always happy being "baka" person.... so i can learn much more cheers, chika
Hello,
I have two directories that are almost identical to each other and I need to copy the contents of the source directory over the to the target directory, but without overwriting any files that are newer on the target. Is there an argument that I can use with the 'cp' command to accomplish this?
I have the following to preserve time stamps and permissions; cp -pRv /mnt/userdir /media/userdir
Thank you,
James -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 03 May 2007 21:36, chika@cs.its.ac.id wrote:
cp -u sourceFile targetFile
You can update only the latest file see man cp first (it also work for other command) :D
For more strict u can "set -o noclobber" on cli if u don't wanna overwrite the existing file with older o newest file.
I'm sorry I didn't see this until just now. This applies only to output redirection in the shell (the ">" operator and all the non-appending variants). It has no effect whatsoever on the operation of "cp," which cannot even see that option, which is a shell construct only. Furthermore, while I know this is implemented by BASH, if you use a different shell, you should check first for the equivalent / counterpart in that shell.
For more info
http://www.cyberciti.biz/tips/howto-keep-file-safe-from-overwriting.html
...
chika
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (6)
-
Carlos E. R.
-
chika@cs.its.ac.id
-
James D. Parra
-
M Harris
-
Randall R Schulz
-
riccardo35@gmail.com