Hi All,
I want to take the backup of Only those files in the Directory
/mnt/www/ which are modified in last one day.
For this I am archiving using ‘find’ command, But Its Backing Up all the files
instead of Only selected files. Below the command which I executed…
tar -cvzf daily-backup.tar.gz find /mnt/www/ -mtime -1
Please help me resolve this problem.
Thanks in Advance
Shariq
Restrict the find command to output only files by adding “-type f” to the qualifiers. Otherwise changed directories are also output, and tar will backup all of a directory that has been specified.
Thanks ken_yap. Its working fine now …
very very thanks again…
When I executed the below command to take the backup…
tar -cvzf Dailybackup.tar.gz find /mnt/www/ /mnt/kettle/ /mnt/sentiment/ -type f -mtime -1
I get the error message :
bash: /bin/tar: Argument list too long
I search here and there but did not got the solution.
help is needed …
Thanks
Shariq
Use the --files-from (or -T) option of tar which reads names from the specified file, one per line:
find /mnt/www/ /mnt/kettle/ /mnt/sentiment/ -type f -mtime -1 | tar cvzf Dailybackup.tar.gz -T -
Secondly you may wish to shorten the pathnames by a cd first:
cd /mnt
find www/ kettle/ sentiment/ -type f -mtime -1 | tar cvzf Dailybackup.tar.gz -T -
You will find that tar will throw away the leading / anyway.
It’s always worth looking at the man page or the texinfo of a command for options that will possibly solve your problem, because it’s likely that other people have encountered it in such an old program as tar and the authors have added a solution to the program. That’s how you will get familiar with Linux commands.