I am using this script to tar all files in a directory that were modified last year:
YEAR=$(date +%Y --date='1 year ago')
find /var/www/html/upload/ -maxdepth 1 -newermt "$YEAR-01-01T00:00:00" -not -newermt "$YEAR-12-31T23:59:59" -type f -print0 | xargs -0 tar -cpvzf /home/pete/suitecrm-document-yearly-backup_$YEAR.tar.gz
The find command seems to be working, with some tests, it seems to be providing the correct files.
The issue I am having is that when the archive gets to about 700 meg, the console shows this:
/var/www/html/upload/9e514350-4778-7fbf-4afb-5bd97fc41d11
/var/www/html/upload/b8b5ef47-0376-2446-d0cc-5bb32a509560
tar: Removing leading `/' from member names
/var/www/html/upload/f3278e64-4cfe-f4c0-40b4-5bd97982357b
/var/www/html/upload/5364c7e9-00b2-e4a1-1343-5bd1cf619519
and the archive size is reset back to zero and all the files are removed. This happens a further few times before the script is finished (not always at 700 meg).
The script is being run as root. I have also tried it as a single command, so :
find /var/www/html/upload/ -maxdepth 1 -newermt "2018-01-01T00:00:00" -not -newermt "2018-12-31T23:59:59" -type f -print0 | xargs -0 tar -cpvzf /home/pete/suitecrm-document-yearly-backup_2018.tar.gz
But with the same result.
Any help would be great.