I am trying to make a backups of some files on my server using tar
but I cant seem to get it to do what i want. I've Googled for a solution but i cant seem to find the right one. I want files in /home/me/mysqlDumpFiles
to be included only if they are newer than 1 hour ago but I want all files in /var/www
to be include no matter when they were modified.
dateNow=$(date +%m_%d_%y-%H.%M.%S)
tar czf /home/me/backups/backup-$dateNow.tar.gz /home/me/mysqlDumpFiles --newer-mtime "1 hour ago" /var/www
I appreciate any help i get.
EDIT: I ended up making my own shell script and running that with two separate tar commands
#!/bin/bash
set -e
currentDate=$(date +%Y-%m-%d_%H.%M.%S)
printf "currentDate is $currentDate\n========================================\n"
mkdir /home/me/backupTemp;
mysqldump -uroot -p[CENSORED] [DATABSE_NAME]> /home/me/backupTemp/site.net.sql;
tar -jcf /home/me/mysqlDumpFiles/site.net-$currentDate.tar.bz2 -C /home/me/backupTemp .;
tar -jcf /home/me/backups/backup-$currentDate.tar.bz2 -C /home/me/backupTemp . -C /var/www .;
rm -rf /home/me/backupTemp;
printf "========================================\n"