Esempio n. 1
0
        public bool PerformBackup()
        {
            string backupDirectory = HostingEnvironment.MapPath(this.PostgreSQL.DatabaseBackupDirectory);

            if (backupDirectory == null)
            {
                this.OnOnBackupFail(new BackupProgressInfo(Warnings.BackupDirectoryNotFound));
                return false;

            }

            backupDirectory = Path.Combine(backupDirectory, this.FileName);
            string path = Path.Combine(backupDirectory, "db.backup");
            
            Directory.CreateDirectory(backupDirectory);


            BackupProcess process = new BackupProcess(this.PostgreSQL, path);

            process.Progress += delegate(BackupProgressInfo info)
            {
                BackupProgress progress = this.Progress;

                if (progress != null)
                {
                    progress(new BackupProgressInfo(info.Message));
                }
            };

            process.BackupComplete += delegate(object sender, EventArgs args)
            {
                BackupResource resourceBackup = new BackupResource(backupDirectory);
                resourceBackup.Backup();

                BackupCompression compression = new BackupCompression(backupDirectory);
                compression.Compress(true);

                BackupComplete complete = this.BackupComplete;

                if (complete != null)
                {
                    complete(this, args);
                }
            };

            bool result = process.Execute();

            if (!result)
            {
                this.OnOnBackupFail(new BackupProgressInfo(Warnings.CannotCreateABackup));
                return false;
            }

            return true;
        }
Esempio n. 2
0
        public bool PerformBackup()
        {
            string backupDirectory = HostingEnvironment.MapPath(this.PostgreSQL.DatabaseBackupDirectory);

            if (backupDirectory == null)
            {
                this.OnOnBackupFail(new BackupProgressInfo(Warnings.BackupDirectoryNotFound));
                return(false);
            }

            backupDirectory = Path.Combine(backupDirectory, this.FileName);
            string path = Path.Combine(backupDirectory, "db.backup");

            Directory.CreateDirectory(backupDirectory);


            BackupProcess process = new BackupProcess(this.PostgreSQL, path);

            process.Progress += delegate(BackupProgressInfo info)
            {
                BackupProgress progress = this.Progress;

                if (progress != null)
                {
                    progress(new BackupProgressInfo(info.Message));
                }
            };

            process.BackupComplete += delegate(object sender, EventArgs args)
            {
                BackupResource resourceBackup = new BackupResource(backupDirectory);
                resourceBackup.Backup();

                BackupCompression compression = new BackupCompression(backupDirectory);
                compression.Compress(true);

                BackupComplete complete = this.BackupComplete;

                if (complete != null)
                {
                    complete(this, args);
                }
            };

            bool result = process.Execute();

            if (!result)
            {
                this.OnOnBackupFail(new BackupProgressInfo(Warnings.CannotCreateABackup));
                return(false);
            }

            return(true);
        }