Kaseya Community

Disk Full - How to delete old backups through a script

  • We use BUDR for laptop backups and the destination is to a external USB drive. We run into issues where Kaseya does not delete the oldest backup for various reasons and the backup fails.

    Anyone, know how I could write a script or automate a way to delete the oldest backups on the drive without having to physically logon and go and delete them.

    Legacy Forum Name: Disk Full - How to delete old backups through a script,
    Legacy Posted By Username: mmoore
  • I've been working with a Kaseya support technician on this one. Here's what I've been told:


    Here's how Delete Before Backup is implemented:

    1) When a full backup is scheduled to run, the machine will post a list of which backups are currently on the hard drive.
    2) The machine will then contact a web service on the KServer
    3) The KServer will respond with a batch file of which files need to be deleted (by comparing the list of backup sets on the hard drive versus what the KServer's database thinks should be there)
    4) The machine will execute said batch file
    5) The backup will commence


    The batch file is put in your agent temp directory. Here's an example of what it looks like:

    REM - delete old backups _before_ backing up
    rmdir /S /Q "G:\56942676\VolBackup\20080909 05.00.04"

    The problem we've experienced is, somewhere in steps 1-3, the batch file is generated incorrectly and it's configured to delete the wrong folder. Like in the above example, this was the batch file that ran when it should have deleted this folder:

    G:\56942676\VolBackup\20080903 05.00.03

    The technician told me that this issue was resolved in the SP1 release, but as a workaround I've been using a pre-script that runs a shell command that looks like:

    rmdir /S /Q "G:\56942676\VolBackup"

    Obviously, you need to change the image location and GUID to match your machine.

    rmdir /S /Q "\\VolBackup"

    This will effectively delete all your backups for the machine, so only use this IF you are swapping USB drives (your image location) on a daily basis or if you just need to save 1 backup set.

    Legacy Forum Name: BU-DR,
    Legacy Posted By Username: ahart
  • Thanks for the information. That is helpful.

    Legacy Forum Name: BU-DR,
    Legacy Posted By Username: mmoore
  • So is there a switch to get aconris to delete old backups.
    I have been using a robocopy script to delete files older than 3 weeks, hoping that is about the about of disk space remaining.

    If Kaseya could delete the old backups first it would be great.

    mike

    Legacy Forum Name: BU-DR,
    Legacy Posted By Username: mfelder
  • mfelder
    So is there a switch to get aconris to delete old backups.
    I have been using a robocopy script to delete files older than 3 weeks, hoping that is about the about of disk space remaining.

    If Kaseya could delete the old backups first it would be great.

    mike


    Yes, there is. In Schedule Volume for Folder page there is a option
    "Save last ____ backup sets".

    Legacy Forum Name: BU-DR,
    Legacy Posted By Username: mmoore
  • Did the above post work? (keep previous x sets) I run 2008 SP1 5.1.0.0 and am still having trouble with backups deleting. If someone could confirm it works for them either on 2008 SP1 or previous then I will look deeper into my system before I blame Kaseya.

    Legacy Forum Name: BU-DR,
    Legacy Posted By Username: iamnet
  • iamnet
    Did the above post work? (keep previous x sets) I run 2008 SP1 5.1.0.0 and am still having trouble with backups deleting. If someone could confirm it works for them either on 2008 SP1 or previous then I will look deeper into my system before I blame Kaseya.


    Has always worked for us. We are not on SP1 yet though.

    Legacy Forum Name: BU-DR,
    Legacy Posted By Username: GDRBrian
  • We are using the rmdir shell command here, but we run it once a week an hour before the full volume backup kicks off. The reason we started doing this is that the backup routine won't delete any old backups until the new one is completed first. Our client is doing a full volume backup of about 630 GB of data to an external 1 TB drive once a week and doing differentials every day after. So, as you can imagine just with the full backups alone how hard it would be to stuff 1.26 TB of data onto a 1 TB drive. Fortunately, they have 3 drives that they swap every week about 14 hours before the deletion script runs. For us, the problem was intended functionality. I hope this helps.

    Legacy Forum Name: BU-DR,
    Legacy Posted By Username: TSI-Eric
  • [QUOTE=TSI-Eric;33035]We are using the rmdir shell command here, but we run it once a week an hour before the full volume backup kicks off. The reason we started doing this is that the backup routine won't delete any old backups until the new one is completed first. Our client is doing a full volume backup of about 630 GB of data to an external 1 TB drive once a week and doing differentials every day after. So, as you can imagine just with the full backups alone how hard it would be to stuff 1.26 TB of data onto a 1 TB drive. Fortunately, they have 3 drives that they swap every week about 14 hours before the deletion script runs. For us, the problem was intended functionality. I hope this helps.[/QUOTE]

    I have a ticket in to support to clear this up but I am looking at the "Delete before running backup" option when scheduling a backup. Does anyone know if this option would effectively work without having to run a rmdir command? I am having this same issue with a few clients and didn't want to use the option without knowing exactly what it will do.

    Here is what it says in the help section: "If checked, delete any backups sets not being save before running a new backup."

    If anyone have an experience with this option, please share.

    Thanks.

    //edit: Simply, I am trying to find out if the "Delete before running backup" option will delete the oldest backup week BEFORE a new full backup is ran rather than after the new full backup completes.

    Legacy Forum Name: BU-DR,
    Legacy Posted By Username: GDRBrian
  • I have been using the delete before option but it does not always work. Another unindented result is that if you have a few backups fail and don't realize it, all of your backups may have been deleted depending on how many full backups you are keeping.

    I did open a issue with Kaseya in regard to the backups not always getting deleted and they said there was a hotfix. I have applied the hotfixes but have not yet been able to fully test the result. I am not yet running SP1.

    Legacy Forum Name: BU-DR,
    Legacy Posted By Username: mmoore
  • mmoore
    I have been using the delete before option but it does not always work. Another unindented result is that if you have a few backups fail and don't realize it, all of your backups may have been deleted depending on how many full backups you are keeping.

    I did open a issue with Kaseya in regard to the backups not always getting deleted and they said there was a hotfix. I have applied the hotfixes but have not yet been able to fully test the result. I am not yet running SP1.


    I appreciate the info. I am going to test out the option and see what happens. I'll let you know if I see the same behavior as you and although I don't like the idea that it will delete the old backups before a new full is completed, I currently don't have another option and will definitely be visually confirming the backups as to not loose at least one full week.

    Thanks.

    Legacy Forum Name: BU-DR,
    Legacy Posted By Username: GDRBrian