Пример #1
0
    def build_config(self):
        log.trace("build_config")
        #store1 = FTPStore("teststore1", "4MB", True, "localhost", "store1", "ftpuser", "ftpuserX9", False)
        #store2 = FTPStore("teststore2", "4MB", True, "localhost", "store2", "ftpuser", "ftpuserX9", False)
        if self.options.store:
            store1 = self.config.storage[self.options.store].copy()
            store2 = store1
        else:
            #    Make the store about 3x the options size
            s, dummy, dummy = utils.from_readable_form(self.options.size)
            store_size = utils.readable_form(s * 3)
            store1 = FolderStore("teststore1", store_size, True, os.path.join(self.store_folder, "teststore1"))
            store2 = FolderStore("teststore2", store_size, True, os.path.join(self.store_folder, "teststore2"))
            self.config.storage[store1.name] = store1
            self.config.storage[store2.name] = store2

        backup1 = Backup("testbackup1")
        backup1.include_folders = [self.files_folder]
        backup1.include_packages = True
        backup1.exclude_types = ["Music"]
        backup1.exclude_patterns = []
        backup1.store = store1.name
        backup1.notify_msg = False
        self.config.backups[backup1.name] = backup1

        backup2 = Backup("testbackup2")
        backup2.include_folders = [self.files_folder]
        backup2.include_packages = True
        backup2.exclude_patterns = []
        backup1.exclude_types = ["Videos", "Programs"]
        backup2.store = store2.name
        backup2.notify_msg = False
        self.config.backups[backup2.name] = backup2
Пример #2
0
    def save(self):
        #    BUILD THE BACKUP
        if len(self.txtName.GetValue()) == 0:
            raise Exception(_("Backup name cannot be blank"))
        if self.chkEncrypt.GetValue() and not self.config.data_passphrase:
            raise Exception(_("You cannot select encryption when the passphrase is blank (see Configuration page)."))
        if self.txtName.GetValue() == EmptyName:
            raise Exception(_("You need to provide a proper backup name"))
        try:
            #    Create the new backup object
            b = Backup(self.txtName.GetValue())
            #    General Information
            b.active = self.chkActive.GetValue()

            #    Folder Information
            b.include_folders = self.text_to_list(self.txtFolders.GetValue())
            b.include_packages = self.chkPackages.GetValue()

            #    Exclusions
            b.exclude_types = list(self.lstExcludeTypes.GetCheckedStrings()) # returns a tuple, convert to array
            b.exclude_patterns = self.text_to_list(self.txtExcludePatterns.GetValue())

            #    Destination
            b.store = self.cboStore.GetStringSelection()
            b.encrypt = self.chkEncrypt.GetValue()
            b.verify = self.chkVerify.GetValue()

            #    Schedule
            if self.radSchedAdvanced.GetValue():
                b.sched_type = "custom"
                b.sched_times = "%s\n%s" % (self.txtCronIncr.GetValue(), self.txtCronFull.GetValue())
            else:
                if self.radSchedDailyWeekly.GetValue():
                    b.sched_type = "daily/weekly"
                    time = self.cboTime1.GetStringSelection()
                    day = self.cboDay1.GetStringSelection()
                elif self.radSchedDailyMonthly.GetValue():
                    b.sched_type = "daily/monthly"
                    time = self.cboTime2.GetStringSelection()
                    day = self.cboMonthDay2.GetStringSelection()
                elif self.radSchedHourlyWeekly.GetValue():
                    b.sched_type = "hourly/weekly"
                    time = self.cboTime3.GetStringSelection()
                    day = self.cboDay3.GetStringSelection()
                elif self.radSchedNoneDaily.GetValue():
                    b.sched_type = "none/daily"
                    time = self.cboTime4.GetStringSelection()
                    day = "*"
                elif self.radSchedNoneWeekly.GetValue():
                    b.sched_type = "none/weekly"
                    time = self.cboTime5.GetStringSelection()
                    day = self.cboDay5.GetStringSelection()
                else:
                    raise Exception(_("Corrupt backup"))

                b.sched_times = time + "/" + day

            #    Notifications
            b.notify_msg = self.chkNotifyMsg.GetValue()
            b.notify_email = self.chkNotifyEmail.GetValue()
            b.shutdown_after = self.chkShutdown.GetValue()

            b.check()
        except Exception as e:
            raise e
        if self.state == ViewState:
            #    Delete the old name
            oldname = self.lstItems.GetStringSelection()
            try:
                del self.config.backups[oldname]
            except:
                pass
        self.config.backups[b.name] = b
        self.config.save()
        self.update_backup_list()

        #    Attempt to save the crontab. If this fails, the backup was corrupt.
        #    But it has been saved. So that is a problem
        update_crontab(self.config.backups)
Пример #3
0
def build_config(conf):
    #    This is called to build a default config object
    #    It is used the first time this application is run.
    log.info("Building new config object")

    conf.version = 1
    conf.file_types = {_("Images"): ["jpg", "jpeg", "raw",
                                     "cr2", "png", "gif", "dng", "tiff",
                                        "tif", "bmp", "svg", "ppm", "psd"],
                     _("Videos"): ["avi", "mpg", "mpeg", "mp4", "mov", "m4v", "vob", "wmv", "flv"],
                     _("Music"): ["mp3", "aac", "ogg", "flac", "wav", "wma", "mpa"],
                     _("Programs"): ["bin", "dll", "exe", "com", "lib"]
                     }

    conf.storage = {}
    store = FolderStore(_("System Backup Folder"), "", False, os.path.join(const.DataDir, "vault-store"))
    conf.storage[store.name] = store

    #    By default, the data passphrase is blank.
    conf.data_passphrase = None

    conf.backups = {}
    
    b = Backup(_("Home"))
    b.include_folders = ["/home"]
    b.active = False
    b.include_packages = True
    b.store = store.name
    b.notify_msg = True
    conf.backups[b.name] = b

    conf.mail_server = ""
    conf.mail_port = 25
    conf.mail_ssl = False
    conf.mail_auth = False
    conf.mail_login = ""
    conf.mail_password = ""
    conf.mail_from = ""
    conf.mail_to = ""


    if const.Debug:

        #    If we are debugging, we create debug store and backup objects
        store = FolderStore("TestStore", "20MB", True,
                        os.path.join(const.RunDir, "store"))
        conf.storage[store.name] = store


        b = Backup("test")
        b.include_folders = [os.path.join(const.RunDir, "files")]
        b.include_packages = True
        b.exclude_types = ["Videos", "Programs"]
        b.exclude_patterns = ["*/not"]
        b.store = store.name
        b.notify_msg = True
        b.encrypt = True
        conf.backups[b.name] = b

        #    DEBUG - reset the store and include folders
        conf.backups["Home"].store = store.name
        conf.backups["Home"].include_folders = [os.path.join(const.RunDir, "files")]