carstein.seeberg

NAS Script: Create a compressed backup of the NAS database

Discussion created by carstein.seeberg on Jun 14, 2010
Latest reply on Jun 22, 2010 by carstein.seeberg

Just went through some of my scheduled jobs and found something that could be useful for others. This script uses the database interfaces and file interfaces to copy the database.db file and performs a "vacuum" (reorganize).  It sends an email when its done.

 

Carstein

 

 

-- Creates a live-backup and vacuums the database --   backup = "database.db.bak"  -- Copy the "hot" database file.copy    ("database.db",backup)  -- Compress the backup database database.open  (backup) database.query ("VACUUM;") database.close ()  sbuf = file.stat (backup) if sbuf.size > 1000000 then    size = sbuf.size / 1000000    ext  = "MB" else    size = sbuf.size / 1000    ext  = "KB" end   msg = sprintf("Created backup database '%s:%s', size: %0.1f %s",NAS_NAME,backup,size,ext)  print (msg)  action.email ("user@company.com",msg,"NAS database has been backed up and compressed")

Outcomes