Пример #1
0
def wiz_execute(wiz):
    log.debug("Executing backup creation wizard")
    config = Config.get_config()    
    name = wiz.fields["name"].value
    path = wiz.fields["folderpath"].value
    excl = []
    for typ in config.file_types.iterkeys():
        if wiz.fields['excl-'+typ].value:
            excl.append(typ)
    store = wiz.fields["store"].value
    
    b = Backup(name)
    b.active = True
    b.include_folders = [path]
    b.include_packages = True
    b.exclude_types = excl
    b.store = store
    b.excrypt = False
    b.sched_type = "daily/weekly"
    b.sched_times = "19:00/Sun"    
    b.verify = False
    b.notify_msg = True
    b.notify_email = False
    b.shutdown_after = False
    
    config.backups[name] = b
    config.save()
    update_crontab(config.backups)
    
    

    dlg.Info(wiz, _("Your backup has been successfully created."))
    app.broadcast_update()
Пример #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")]