You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
738 B
22 lines
738 B
1 year ago
|
#!/bin/bash
|
||
|
|
||
|
PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
|
||
|
|
||
|
#Use backup_clean.sh <logfile> <remote_server> <remote_path>
|
||
|
|
||
|
LOG_FILE=$1
|
||
|
REMOTE_SERVER=$2
|
||
|
REMOTE_PATH=$3
|
||
|
BACKUP_PRESERVE_DAYS=21
|
||
|
|
||
|
echo "\n[NEW BACKUP TASK] Clear $BACKUP_PRESERVE_DAYS days old backups\n" >> $LOG_FILE
|
||
|
echo "\nThese are the remaining backups:\n"
|
||
|
# Clear X days old remote logs
|
||
|
ssh $REMOTE_SERVER 'bash -s' << EOF >> $LOG_FILE
|
||
|
find $REMOTE_PATH -maxdepth 1 -mtime +$BACKUP_PRESERVE_DAYS -print -exec "rm" -R {} \;
|
||
|
find $REMOTE_PATH -mindepth 1 -maxdepth 1 -mtime -$BACKUP_PRESERVE_DAYS -print | sort -n
|
||
|
EOF
|
||
|
|
||
|
echo "\n[DONE BACKUPS] Clear old backups completed!\n" >> $LOG_FILE
|
||
|
echo "########################################################" >> $LOG_FILE
|