com.marringtons.object
Class Backup

java.lang.Object
  extended bycom.marringtons.object.Backup
All Implemented Interfaces:
IdleInterface

public class Backup
extends Object
implements IdleInterface

The database system needs procedures for backing up and restoring all changes. This class includes the relevant methods - and a daemon to do it at specific time. All methods are static, but Database refers to it to initialise the backup daemon. All backups are part of the idle process to minimise the effect on the running system. It is controlled by 2 properties in any previously loaded property file.

database.backup.name

If this parameter does not exist, no periodic backups are made. If it does exist it specifies the path and the start of the name for the backups. At backup time a file is created by appending a time stamp and ending in .zip. So, "~/backup/" will create files with just stamp.zip in a backup directory under the user home directory. "~/backup/backup" will do the same except each file starts with "backup".

database.backup.time

Is the time of day or interval between backups. The last backup when the program was last run is taken into account. If there was no previous backup then one will occur after 5 minutes from program start. 12:00:00 // every midday 7 20:00:00 // once a week at 8pm +2 12:00:00 // every 2-1/2 days from start time +0:30:00 // every 30 minutes Examples
 Backup.backupAll();	// backs up all open databases
 
 ZipOutputStream zip = new ZipOutputStream( Output.makeUnique( "testBackup", "zip"), false);
 Backup.backupAll( zip);	// backs up all open databases to an archive
 
 Backup.restoreAll( archiveName);
 
The backup daemon is started when this class is first accessed (by Database).

Author:
Paul Marrington

Method Summary
static String[] backupAll()
          Back up all active databases to a unique to unique XML files of the same names in the default output directory.
static String[] backupAll(ZipOutputStream zip)
          Back up all active databases to the supplied archive.
static void restoreAll(String archiveName)
          Restore all databases from an archive.
 void whileIdling()
          The database is backed up regularly as part of the idle process.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

backupAll

public static String[] backupAll()
                          throws IllegalArgumentException,
                                 IOException,
                                 IllegalAccessException,
                                 InstantiationException
Back up all active databases to a unique to unique XML files of the same names in the default output directory.

Returns:
List of String backup file names
Throws:
InstantiationException
IllegalAccessException
IOException
IllegalArgumentException

backupAll

public static String[] backupAll(ZipOutputStream zip)
                          throws IllegalArgumentException,
                                 IOException,
                                 IllegalAccessException,
                                 InstantiationException
Back up all active databases to the supplied archive.

Parameters:
zip - Archive to hold backup.
Returns:
List of String backup file names
Throws:
InstantiationException
IllegalAccessException
IOException
IllegalArgumentException

restoreAll

public static void restoreAll(String archiveName)
                       throws XMLexception,
                              IOException
Restore all databases from an archive. The databases are closed then deleted before the restore. Next time an item from the database is accessed it will be reopened. It is essential that this routine be called in a single-user environment without any chance of another thread requiring the data. Note that a restore not only restores a database to a known state, it also cleans it up - compressing and defragmenting the resident data. The file may be inside an archive or part of the file system.

Parameters:
archiveName - name of a zip archive containing XML backup files
Throws:
IOException
XMLexception

whileIdling

public void whileIdling()
The database is backed up regularly as part of the idle process. It requires a backup directory and backup interval

Specified by:
whileIdling in interface IdleInterface
See Also:
IdleInterface.whileIdling()


Copyright © 2005 Paul Marrington http://library.marringtons.com