1752679 Members
5544 Online
108789 Solutions
New Discussion юеВ

incremental backup fail

 
Maaz
Valued Contributor

incremental backup fail

/devel_x098 is a samba server share(windows xp users access this directory)...and I have to take regular backups of this directory(/devel_x098)

test-back:/devel_x098 # find /devel_x098/AchDev_dvl1/ -mtime -1 -type f -print
/devel_x098/AchDev_dvl1/M AHSAN/text/16BIT_roof108_ROOF.jpg
/devel_x098/AchDev_dvl1/M AHSAN/text/New Folder/Thumbs.db
/devel_x098/AchDev_dvl1/M AHSAN/text/New Folder/brick222225.psd
/devel_x098/AchDev_dvl1/ADEEL AHMED/STATUS REPORT OF 09-07-09.ods

test-back:/devel_x098 # find /devel_x098/AchDev_dvl1/ -mtime -1 -type f -exec cp -rv bck/ {} \;
cp: cannot overwrite non-directory `/devel_x098/AchDev_dvl1/M AHSAN/text/16BIT_roof108_ROOF.jpg' with directory `bck/'
cp: cannot overwrite non-directory `/devel_x098/AchDev_dvl1/M AHSAN/text/New Folder/Thumbs.db' with directory `bck/'
cp: cannot overwrite non-directory `/devel_x098/AchDev_dvl1/M AHSAN/text/New Folder/brick222225.psd' with directory `bck/'
cp: cannot overwrite non-directory `/devel_x098/AchDev_dvl1/ADEEL AHMED/STATUS REPORT OF 09-07-09.ods' with directory `bck/'

test-back:/devel_x098 # ls bck/
test-back:/devel_x098 #

test-back:/devel_x098 # find /devel_x098/AchDev_dvl1/ -mtime -1 -type f -exec cp -v bck/ {} \;
cp: omitting directory `bck/'
cp: omitting directory `bck/'
cp: omitting directory `bck/'
cp: omitting directory `bck/'
test-back:/devel_x098 # ls bck/
test-back:/devel_x098 #

the 'bck' is empty.

please help
3 REPLIES 3
Steven Schweda
Honored Contributor

Re: incremental backup fail

> [...] -exec cp -rv bck/ {} \;

> [...] exec cp -v bck/ {} \;

Are you trying to copy "bck/" into some file,
or some file into "bck/"?

"man cp"?

When you figure out the difference between
cp a b
and
cp b a
you might also wish to look at "cp -p".
Maaz
Valued Contributor

Re: incremental backup fail

thanks Steven for reply

I got the mistake the right way is

find /devel_x098/AchDev_dvl1/ -mtime -1 -type f -exec cp -v {} bck/ \;
and the command is working.

But instead of running the above command, if I run the following command
find /devel_x098/AchDev_dvl1/ -mtime -1 -type d -exec cp -rv {} bck/ \;

then if a single file is modified/created the whole directory backs up.

e.g under "/devel_x098/AchDev_dvl1/TEST/CORE", if I just create a file or modified a file, then complete "devel_x098/AchDev_dvl1/TEST/CORE" backs up.

actually I want to use the second command because I have several 'same name' file under sub-directories of "/devel_x098/AchDev_dvl1/", so I want to sustain the directories too.

Regards






Steven Schweda
Honored Contributor

Re: incremental backup fail

> [...] I want to sustain the directories
> too.

"tar" may be more useful than "cp" for this.
For example:

ra# mkdir bck
ra# tar cf - root/fred/lame1.c | ( cd bck ; tar xf - )
ra# ls -lR bck
bck:
total 2
drwxr-xr-x 3 root root 512 Jul 28 10:09 root

bck/root:
total 2
drwxr-xr-x 2 root root 512 Jul 28 10:09 fred

bck/root/fred:
total 2
-rw-r--r-- 1 root root 192 Mar 5 2008 lame1.c
ra#


GNU "tar" has some more helpful options to
use in situations like this, but any old
"tar" can be made to work. A Forum search
for keywords like
tar pipeline
may find more detailed examples.