Bash script to delete files from remote FTP older than 7 days -


i got bash script internet, good. backup, upload ftp, delete old backups older 7 days.

but not delete old backup older 7 days in remote ftp

#!/bin/sh mdate="$(date +"%d-%m-%y")" mysqldump -uroot -ppassword asia stats | gzip > /home/backup/asia_$mdate.$  cd /home/backup/  ftpserver="ftp.drivehq.com" ftpuser="username" ftppass="password"  ftp -n -i $ftpserver <<eof user $ftpuser $ftppass cd backupstats mput asia_$mdate.gz quit eof  find /home/backup/asia_*.gz -maxdepth 1 -type f -mtime +7 -delete 

the example backup name "asia_17-08-2014.gz"

thanks in advance help.

generally easiest way keep files 7 days name them .mon, .tue, etc. overwrite previous week's file every monday, tuesday, etc.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -