Tweaking backups

Hi,

I’d like to be able to “tweak” the backups so that the directory where they get stored is emptied before the backups are done. I’ve been checking here: http://interworx.com/support/docs/iworx-cp/sysadmin/siteworx/backup-restore/howto-create-backup and I can’t see anything that might help.

The problem is that we are doing FULL backups of our sites and every 5-6 days the backup disk gets full.

Regards,

I made an adjustment to the /home/interworx/iworx.ini file. I’m not sure if this is best practice or not. The line you want to look for is:

[iworx.backup]
filename_format="%D-%t-%b.%d.%Y-%H.%M.%S"

What I did was change the string to:

filename_format="%D-%t"

This will make the backups save as ‘domain-type.tgz’ without the timestamp. It will overwrite the files every backup because they would continue to repeat the same filename.

But of course, you can set this up however you like. You can do each day of the week if you wanted ( filename_format="%D-%a" ). Here are the options:

  • %D=domain name,
  • %T=unix timestamp,
  • %U = unix username,
  • %R = reseller id,
  • %t = backup type (full or partial),
  • %H = hour,
  • %M = minute,
  • %S = second,
  • %m = month (1..12),
  • %d = day of month (1..31),
  • %a = 3-letter day of week (Sun..Sat),
  • %Y = 4-digit year"
Cheers. :)

[QUOTE=Poooh;14550]Hi,

I’d like to be able to “tweak” the backups so that the directory where they get stored is emptied before the backups are done. I’ve been checking here: http://interworx.com/support/docs/iworx-cp/sysadmin/siteworx/backup-restore/howto-create-backup and I can’t see anything that might help.

The problem is that we are doing FULL backups of our sites and every 5-6 days the backup disk gets full.

Regards,[/QUOTE]

I had the same problem when I had the siteworx account (iworx hosting) and I think I also suggested the iworx guys for a feature to remove old backups.

If you overwrite and if something goes wrong, it could become a backup less situation. Rare, but could happen. By deleting old files you are safe, and you have previous backups too.

I had the following script on a daily cron to delete old backups.
(deletes all but the recent 2 backups)

file: delold-backups.php (placed in the dir where backups are saved)



<?php

require '../example.com/delold-inc.php';

DeleteOldFiles("example.com*.tar.gz", 2);

?>


file: delold-inc.php



<?php

function DeleteOldFiles($wild, $tokeep)
{
  $files = glob("./" . $wild);
  if (!$files)
    return;

  usort($files, "cmp");

  $todel = count($files) - $tokeep;
  for ($i = 0; $i < $todel; $i++) {
    unlink($files[$i]);
    //print "Deleted $files[$i]
";
  }
}

function cmp($a, $b)
{
  $sa = filemtime($a);
  $sb = filemtime($b);
  if ($sa == $sb)
    return 0;
  return ($sa < $sb) ? -1 : 1;
}

?>


Hope this helps.