shell - bash unix incremental script backup issue with omitting directories -
i working on incremental backup backup files modified in last 24 hours. trying avoid copying directories can seeing tree command. maybe it's cpio doing it. don't know alternative of ignoring folders. backup works fine copies directories starting root , destination of files. can copy files , not directories within entire $bksource.
#!/bin/bash bkdest="/home/user/backup/incremental" bksource="/home/user/documents" target=${bkdest}/bk.inc.$(date +%y_%m_%d_%h_%m_%s) mkdir -p $target find "$bksource" -type f -mtime 0 | cpio -mdp "$target" here tree after backup. seeing last 24 hours modified files brought folders directories backups last modified files in documents good.
[user@localhost bk.inc.2015_08_02_21_56_41]$ tree . └── home └── user └── documents ├── newinc1 ├── newinc2 └── newinc3 if has solution, appreciate that. thank you!
rsync -av --exclude='path1/to/exclude' --exclude='path2/to/exclude' bksource bkdest note using source , source/ different. trailing slash means copy contents of folder source destination. without trailing slash, means copy folder source destination.
alternatively, if have lots of directories (or files) exclude, can use --exclude-from=file, file name of file containing files or directories exclude.
--exclude may contain wildcards, such --exclude=*/.svn*
update: transfer list of files obtained find command absolute paths, might like:
rsync -av --files-from=/path/to/files.txt / /destination/path/ you can make use of --dry-run test files
Comments
Post a Comment