001package jmri.jmrit.operations.setup;
002
003import java.io.File;
004import java.io.IOException;
005
006/**
007 * Specific Backup class for backing up and restoring Operations working files
008 * to the Automatic Backup Store. Derived from BackupBase.
009 *
010 * @author Gregory Madsen Copyright (C) 2012
011 */
012public class AutoBackup extends BackupBase {
013
014//    private final static Logger log = LoggerFactory.getLogger(AutoBackup.class);
015
016    /**
017     * Creates an AutoBackup instance and initializes the root directory to the
018     * given name.
019     */
020    public AutoBackup() {
021        super("autoBackups"); // NOI18N
022    }
023
024    /**
025     * Backs up Operations files to a generated directory under the automatic
026     * backup root directory.
027     *
028     * @throws java.io.IOException Due to trouble accessing files
029     */
030    public synchronized void autoBackup() throws IOException {
031
032        // Get a name for this backup set that does not already exist.
033        String setName = suggestBackupSetName();
034
035        copyBackupSet(getOperationsRoot(), new File(getBackupRoot(), setName));
036    }
037}