I am working on the incremental backup to backup files that were modified in the last 24 hours. I am trying to avoid copying all the directories as can be seeing from the tree command. Maybe it's cpio that is doing it. Don't know the alternative of ignoring all the folders. The backup works perfectly fine but its just that it copies all the directories as well starting from the root and to the destination of the files. What can I do to copy just the files and not the directories within the 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 is the tree after the backup. I am seeing all the last 24 hours modified files but it brought folders directories with it as but only backups last modified files in the Documents which is good.
[user@localhost bk.inc.2015_08_02_21_56_41]$ tree
.
└── home
└── user
└── Documents
├── newinc1
├── newinc2
└── newinc3
If someone has a solution, I would really appreciate that. Thank you!