in reply to Need help with mysql dump script
Now I updated my code and it works! :) Thanks! I found another way to delete files that are older than x days, however, something strange came up... I don't know why it happened, but if I use the second delete section like this:
#### #### Check for expired backups #### print $backup_daily_subdir."\n"; die unless chdir "$backup_daily_subdir"; die unless opendir DIR, "."; foreach $file (grep {-f && (31 < -M)} readdir DIR) { unlink $file; } closedir DIR; print $backup_weekly_subdir."\n"; die unless chdir "$backup_weekly_subdir"; die unless opendir DR, "."; foreach $files (grep {-f && (365 < -M)} readdir DR) { unlink $files; } closedir DR;
I get this error:
~/perl/sandbox]$ ./newtime.pl Name "main::files" used only once: possible typo at ./newtime.pl line +59. Name "main::isdst" used only once: possible typo at ./newtime.pl line +16. Name "main::yday" used only once: possible typo at ./newtime.pl line 1 +6. The file for this hour already exists! Died at ./newtime.pl line 57.
Line 57 is -> die unless chdir "$backup_weekly_subdir";
I got rid of the chdir part to make it work and used only opendir, but why was this happening with chdir(i mean the die on line 57)? "./backup/weekly" was missing so you were right jethro, but I created it, and it was there, I even printed the variables and tried an ls command on it and it was working... I'm clueless, is this safe what I'm doing, or I can wipe something out that I don't want?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need help with mysql dump script
by toolic (Bishop) on Aug 18, 2011 at 00:56 UTC | |
by repcsi (Initiate) on Aug 18, 2011 at 14:57 UTC | |
by jethro (Monsignor) on Aug 19, 2011 at 12:06 UTC |