Associate
- Joined
- 8 May 2009
- Posts
- 296
I've set up a cronjob to execute a backup script every 24 hours. It works almost perfectly except for this:
The issue I've identified is that the backup files are named with spaces in the file name... I know I could just change the output so they don't have spaces, but I'm curious to solve it anyway just for experience.
As an example, out put files are:
home-backup-22 October 2016
home-backup-23 October 2016
home-backup-24 October 2016
home-backup-25 October 2016
home-backup-26 October 2016
...
So the command fails saying something like No such file: home-backup-22... obviously missing off the month/year due to the space.
Any ideas on how to tell it to do the whole file name including spaces?
Thanks
Code:
## SET THE BACK UP ROOT DIRECTORY ##
BACKUP_DIR=/home/backup
## CLEAN UP THE OLDER FILES - REMOVE OLDER FILES ##
rm `find $BACKUP_DIR/HOME/* -type f -mtime +3`
The issue I've identified is that the backup files are named with spaces in the file name... I know I could just change the output so they don't have spaces, but I'm curious to solve it anyway just for experience.
As an example, out put files are:
home-backup-22 October 2016
home-backup-23 October 2016
home-backup-24 October 2016
home-backup-25 October 2016
home-backup-26 October 2016
...
So the command fails saying something like No such file: home-backup-22... obviously missing off the month/year due to the space.
Any ideas on how to tell it to do the whole file name including spaces?
Thanks