I have a backup ftp server and I have a CRON bash sending all backups here.
Right now I have to manually delete all old files, but I would like to automate this process with a CRON bash
The remote FTP does'nt have date on files (I don't know why), but backups are named by date (%Y-%m-%d-%H-%M-%S).
I thought of listing all files in the directory, sorting them by name and deleting all files with index > X but I don't know how to do that
My current code is :
ftp -inv $ftphost << EOF
user $ftpuser $ftppass
put $savepath.bz2 mysql/"$dbname"/"$datum".sql.bz2
bye
EOF
Best Answer
This solution certainly isn't waterproof but if your backup job runs daily and you want to keep 1 month worth of backups you could delete the file that is one month old with something like:
And then in the FTP section
Depending on the FTP server you mau need to toggle
glob
first. Themls
command should tell you whether or not the file name expansion works.