#20 Backups of Important Files

open
Morbus Iff
None
5
2003-12-16
2003-12-16
Morbus Iff
No

AmphetaDesk should support backups of the data/
myChannels.opml and data/mySettings.xml files - one
should be made every couple of days, and the last five
iterations should be kept hanging around. I've got code to do
this already somewhere, just a matter of finding it again.

Discussion

  • Morbus Iff
    Morbus Iff
    2003-12-16

    Logged In: YES
    user_id=69804

    Here's that old code, sure to be slaughtered due to wordwraps:

    # wipe out old backups. we keep, at most, five weeks worth.
    # open the backup directory, get the files, and sort by name
    (date).
    opendir(DIR, $backup_files_to) or die "couldn't open backup dir:
    $!";
    my @files = grep /^[^\.]/, readdir(DIR); closedir(DIR); @files =
    sort @files;

    # get the total number of files. we use this to figure out how
    # many files we want to delete by going that far into the array
    # (if there are 20 files, then we need to delete the first 15).
    my $total_files = scalar @files;
    for (my $i = 0; $i < $total_files - 5; $i++) {
    unlink "$backup_files_to$files[$i]";
    print "Removing old backup files: $backup_files_to$files[$i]\n";
    }