Hello,
I've created two directories, one for database backup and one for public_html backup.
Current cron jobs that works fine, are:
For daily database backup:
mysqldump --opt -Q -u myuser -p'mypassword' --all-databases > /home/myuser/backupdb/databases_$(date +"\%Y_\%m_\%d_\%T").sql
For daily public_html backup:
tar -cvpzf /home/myuser/backupdir/files_$(date +"\%Y_\%m_\%d_\%T").tar.gz /home/myuser/public_html
So, I need cron job commant for auto delete those backups older than 4 days after a new one is generated.
I tried these commands for auto delete the backup of the database and public_html older than 4 days but doesn't work:
find /home/myuser/backupdb/ -name "*.sql" -type f -mtime +4 -exec rm -f
find /home/myuser/backupdb/files* -type f -mtime +4 | xargs rm
Best Regards!
I've created two directories, one for database backup and one for public_html backup.
Current cron jobs that works fine, are:
For daily database backup:
mysqldump --opt -Q -u myuser -p'mypassword' --all-databases > /home/myuser/backupdb/databases_$(date +"\%Y_\%m_\%d_\%T").sql
For daily public_html backup:
tar -cvpzf /home/myuser/backupdir/files_$(date +"\%Y_\%m_\%d_\%T").tar.gz /home/myuser/public_html
So, I need cron job commant for auto delete those backups older than 4 days after a new one is generated.
I tried these commands for auto delete the backup of the database and public_html older than 4 days but doesn't work:
find /home/myuser/backupdb/ -name "*.sql" -type f -mtime +4 -exec rm -f
find /home/myuser/backupdb/files* -type f -mtime +4 | xargs rm
Best Regards!