Exemple #1
0
        protected virtual Storage GetStorage(StorageCred storageCred)
        {
            Storage storage = new Storage();

            storage.Connect(storageCred.Name, storageCred.Key);
            return(storage);
        }
Exemple #2
0
 public void LoadSettings()
 {
     StorageCred = new StorageCred()
     {
         Name = Convert.ToString(Properties.Settings.Default.BackupAzureAccountName ?? ""), Key = Convert.ToString(Properties.Settings.Default.BackupAzureAccountKey ?? "")
     };
     BackupStorageCred = new StorageCred()
     {
         Name = Convert.ToString(Properties.Settings.Default.BackupBackupAzureAccountName ?? ""), Key = Convert.ToString(Properties.Settings.Default.BackupBackupAzureAccountKey ?? "")
     };
     Copies           = Convert.ToInt32(Properties.Settings.Default["Copies"] ?? 14);
     ContainersPrefix = "duradosappsys";
 }
Exemple #3
0
        public void Backup(StartBackupEventHandler startBackupCallback, EndBackupEventHandler endBackupCallback, StartBackupContainerEventHandler startBackupContainerCallback, EndBackupContainerEventHandler endBackupContainerCallback, StorageCred storageCred = null, StorageCred backupStorageCred = null, int copies = 14, string containersPrefix = "duradosappsys")
        {
            Dictionary <string, Exception> exceptions = new Dictionary <string, Exception>();



            try
            {
                BackupStartedEventArgs e = new BackupStartedEventArgs()
                {
                    Occured = DateTime.Now, StorageName = storageCred.Name
                };

                Storage storage       = GetStorage(storageCred);
                Storage backupStorage = GetStorage(backupStorageCred);
                var     containers    = storage.ListContainers(containersPrefix);

                if (startBackupCallback != null)
                {
                    e.ContainersCount = containers.Count();
                    startBackupCallback(this, e);
                }

                foreach (var container in containers)
                {
                    if (startBackupContainerCallback != null)
                    {
                        startBackupContainerCallback(this, new BackupContainerStartedEventArgs()
                        {
                            Occured = DateTime.Now, Container = container
                        });
                    }
                    try
                    {
                        DateTime?lastModified = null;
                        bool     modified     = BackupContainer(container, backupStorage, storage, copies, out lastModified);
                        if (endBackupContainerCallback != null)
                        {
                            endBackupContainerCallback(this, new BackupContainerEndedEventArgs()
                            {
                                Occured = DateTime.Now, Container = container, LastModified = lastModified, Modified = modified
                            });
                        }
                    }
                    catch (Exception exception)
                    {
                        exceptions.Add(container.Name, exception);
                        if (endBackupContainerCallback != null)
                        {
                            endBackupContainerCallback(this, new BackupContainerEndedEventArgs()
                            {
                                Occured = DateTime.Now, Container = container, Exception = exception
                            });
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                exceptions.Add("general", exception);
            }
            finally
            {
                if (endBackupCallback != null)
                {
                    endBackupCallback(this, new BackupEndedEventArgs()
                    {
                        Occured = DateTime.Now, StorageName = storageCred.Name, Exceptions = exceptions
                    });
                }
            }
        }
Exemple #4
0
 public void Restore(string appId, StorageCred storageCred = null, StorageCred backupStorageCred = null)
 {
 }