I have a backup script (backup.sh
) that ssh's into another machine, compresses a file, and then scp's this file (backup_data.tar.gz
) back to my local machine. I also have a logrotate file on my local machine:
/opt/backups/backup_data.tar.gz {
nocompress
daily
rotate 7
extension .tar.gz
missingok
postrotate
/opt/backups/backup.sh
endscript
}
Therefore, the first time the logrotate is executed, the log file to rotate isn't there (since the backup.sh script hasn't been executed yet). I have missingok, so it moves on and doesn't throw an error, but it doesn't seem like backup.sh is executed since after the first run, the backup_data.tar.gz still isn't there. I believe postrotate only executes if the file is rotated, is there a way to get around this and have it execute regardless?