To backup existing files with number suffixes, I can do the following:
cp --backup=numbered afile /path/to/dest
But this does not apply when I try to do the same with a folder:
cp -R --backup=numbered afolder /path/to/dest
How can I achieve this?
Maybe I should demonstrate a bit what I want to achieve. First we have two dirs:
ls -ld source container
drwxrwxr-x 6 kaiyin kaiyin 4096 Nov 29 22:11 container
drwxrwxr-x 2 kaiyin kaiyin 4096 Nov 29 22:09 source
Then we do this:
myPerfectCp -R --backup=numbered source container/
myPerfectCp -R --backup=numbered source container/
myPerfectCp -R --backup=numbered source container/
myPerfectCp -R --backup=numbered source container/
Ideally I want this result:
tree container/
container/
├── source
├── source.~1~
├── source.~2~
└── source.~3~
backup.~1~
,backup~2~
etc. you wantdir~1~
containingbackup~1~
, followeddir~2~
containingbackup~2~
and so on, thus tracking each change of state in a separate directory. Is this right? – erch Nov 29 '13 at 18:11