22
Feb 14

I refuse to buy backup software

So, I’m writing a powershell script that:

  • Uses volume shadow service to take a backup of a directory
  • Compresses the above backup using 7zip / whatever
  • Time/Datestamps the compressed backup and copies it off-server to a given location
  • Looks at the above location and deletes backup zips older than a given number of days (i.e. retention period), e.g. keep 30 days of backups
  • But wait, it won’t delete anything unless it knows that a given number of backups exist from the last x days (retention period). After all, if your backups had been failing for 30 days, it would be pretty dumb to delete everything over 30 days old. So the script allows you to set what you deem as a good total number of backups to exist within your retention period in order to delete everything outside of the retention period. Some contingency built in.
  • It connects to your authenticated SMTP server (e.g. Google Mail) to send you an HTML formatted report of exactly what it found in that backup location (filenames alongside their age), whether it detected that recent backups were indeed found, and therefore whether backups older than the retention period were tidied.
  • Obvs, it supports reading / writing to network shares.
  • It supports multiple backup sets per report, using a set of commands like this:

Backup-Tidy 8 6 28 “c:\dir-to-backup” “d:\dir-to-store-zips”
Backup-Tidy 4 2 7 “c:\another-dir-to-backup” “d:\another-dir-to-store-zips”
EmailReport(“hazymat@gmail.com”)

The arguments for Backup-Tidy:

Backup-Tidy 8 6 28 “c:\dir-to-backup” “d:\dir-to-store-zips” “ForReal”

read as follows: “If you find 8 files from the last 6 days, then remove all files over 28 days old”

  • The “ForReal” is a safety belt. Without this argument, the detailed report email is generated but the backups and deletions don’t get done.

And the pretty HTML report looks like this:

Mat’s Backup Tidy Report – 22/02/2014 04:00:36

\\internal.hazymat.co.uk\root\Backup\Mat’s Files [retention period = 28 days]


Recent backups were NOT found. We needed at least 8 zip files 6 days old or less; there are only 3.
We didn’t touch any files; it wasn’t safe to delete anything.

Name Size Age
backup-log-2014.02.19-193402.txt 8k 2d
images-2014.02.19-193402.zip 930m 2d
images-2014.02.18-193409.zip 870m 3d
images-2014.02.17-193355.zip 840m 4d
Total size: 2.6g

 

\\internal.hazymat.co.uk\root\Backup\Big Files [retention period = 7 days]


Recent backups found. We needed at least 5 zip files 7 days old or less; there are 7.
Old files were removed: jolly good.

Name Size Age
backup-log-2014.02.19-193402.txt 8k 0d
images-2014.02.21-193402.zip 930m 0d
images-2014.02.20-193409.zip 870m 1d
images-2014.02.19-193355.zip 840m 2d
images-2014.02.18-193402.zip 930m 3d
images-2014.02.17-193409.zip 870m 4d
images-2014.02.16-193355.zip 840m 5d
images-2014.02.15-193355.zip 840m 6d
Total size: 6.12g

21
Feb 14

One year today

I wanted to write an eloquent status update reflecting my thoughts, beliefs, and status one year on.

But I am so besieged with grief, and so incapacitated by regret that I cannot.

Last night I walked his last journey from Lilac Ward Tolworth Hospital to the tree. It broke me that I could walk back, get in my car and drive home again to a warm home with loved ones.

* Please see my previous post “one week today”