Indigo Backup Script

Posted on
Thu Jan 09, 2020 5:46 am
racarter offline
User avatar
Posts: 468
Joined: Jun 18, 2016
Location: North Yorkshire, UK

Indigo Backup Script

Here's a little script which, if scheduled to run once per day, will backup and zip the Perceptive Automation folder containing your database, plugins and scripts to a location of your choice, then delete backups older than 10 days (or whatever you specify). Have fun!

Code: Select all
import distutils
import distutils.archive_util
import zipfile
import time

path = "/Users/racarter/Documents/Indigo Backups"  #Change this to your desired path
number_of_days = 10  #Change this to the number of days you want to keep backups

def remove(path):
    if os.path.isdir(path):
        try:
            indigo.server.log(" - removing folder %s" % path)
            os.rmdir(path)
        except OSError:
            indigo.server.log( " - unable to remove folder: %s" % path)
    else:
        try:
            if os.path.exists(path):
                indigo.server.log(" - removing file %s" % path)
                os.remove(path)
        except OSError:
            indigo.server.log( " - unable to remove file: %s" % path)

indigo.server.log ("Starting backup; saving to %s" % path )
time_in_secs = time.time() - (number_of_days * 24 * 60 * 60)
for root, dirs, files in os.walk(path, topdown=False):
    for file_ in files:
        full_path = os.path.join(root, file_)
        stat = os.stat(full_path)
        if stat.st_mtime <= time_in_secs:
            remove(full_path)
    if not os.listdir(root):
        remove(root)

archive_filename_template  = "Indigo_Backup_%m_%d_%Y__%H_%M_%S"
archive_filename =  os.path.expanduser ( path + os.sep + time.strftime ( archive_filename_template, time.localtime() ) )
indigo.server.log (" - archive filename %s" % archive_filename + ".zip")
indigo.server.log (" - save path %s" % indigo.server.getInstallFolderPath() )

try:
    distutils.archive_util.make_zipfile ( archive_filename, os.path.expanduser ( indigo.server.getInstallFolderPath()) )
except zipfile.LargeZipFile:
    indigo.server.log ("Zip file too big.  Would require 64 bit extensions")
   
indigo.server.log ("Backup Finished.")

Posted on
Thu Jan 09, 2020 6:03 am
yassi offline
Posts: 468
Joined: Sep 06, 2015
Location: Germany

Re: Indigo Backup Script

Nice, thanks!

Posted on
Thu Jan 09, 2020 6:43 am
tazswe offline
Posts: 211
Joined: Mar 13, 2017
Location: Sweden

Re: Indigo Backup Script

Maybe something for Indigo 8.0


Skickat från min iPad med Tapatalk

Posted on
Thu Jan 09, 2020 9:00 am
Umtauscher offline
User avatar
Posts: 566
Joined: Oct 03, 2014
Location: Cologne, Germany

Re: Indigo Backup Script

Thanks, I tried it and get the error:
"Zip File Error, Would require 64 bit extensions"

Sorry, but what does than mean?
TIA
Wilhelm

Posted on
Thu Jan 09, 2020 9:10 am
racarter offline
User avatar
Posts: 468
Joined: Jun 18, 2016
Location: North Yorkshire, UK

Re: Indigo Backup Script

It means your backup is too big for some reason.

Posted on
Thu Jan 09, 2020 9:30 am
Umtauscher offline
User avatar
Posts: 566
Joined: Oct 03, 2014
Location: Cologne, Germany

Re: Indigo Backup Script

So, I just deleted 5 GB of log files an now it works!
Thanks

Wilhelm

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest