예제 #1
0
 public SyncVolume( XmlNode parentNode )
 {
     mName = PWLib.XmlHelp.GetAttribute( parentNode, "name", "" );
     mSource = VolumeSource.BuildFromXml( parentNode );
     mArchive = BaseArchive.BuildFromXml( parentNode );
     mDatabase = VolumeSnapshotDatabase.LoadFromXml( parentNode );
 }
예제 #2
0
 public SyncVolume(XmlNode parentNode)
 {
     mName     = PWLib.XmlHelp.GetAttribute(parentNode, "name", "");
     mSource   = VolumeSource.BuildFromXml(parentNode);
     mArchive  = BaseArchive.BuildFromXml(parentNode);
     mDatabase = VolumeSnapshotDatabase.LoadFromXml(parentNode);
 }
예제 #3
0
 public SyncVolume( string name, VolumeSource source, BaseArchive archive )
 {
     mName = name;
     mSource = source;
     mDatabase = new VolumeSnapshotDatabase( archive.GetSnapshotXmlDir() );
     mArchive = archive;
 }
        public void MergeSnapshotRevisionsByTimeLimit(VolumeSnapshotDatabase database, VolumeSource source, BaseArchive archive, TimeSpan timePeriodToKeep)
        {
            // only keep revisions within a certain time period (e.g. last 6 months)
            List <VolumeSnapshotRevision> revisionHistory = database.GetRevisionHistory();
            int      numRevisionsToRemove = 0;
            DateTime cutOffDate           = DateTime.Now - timePeriodToKeep;

            foreach (VolumeSnapshotRevision revision in revisionHistory)
            {
                if (revision.CreationTime >= cutOffDate)
                {
                    break;
                }
                else
                {
                    numRevisionsToRemove++;
                }
            }
            if (numRevisionsToRemove > 0)
            {
                FileSync.__Log(this, "Merge will remove " + numRevisionsToRemove + " revisions");
                MergeSnapshotRevisions(database, source, archive, numRevisionsToRemove);
            }
            else
            {
                FileSync.__Log(this, "Merge will not remove any revisions");
            }
        }
예제 #5
0
 public SyncVolume(string name, VolumeSource source, BaseArchive archive)
 {
     mName     = name;
     mSource   = source;
     mDatabase = new VolumeSnapshotDatabase(archive.GetSnapshotXmlDir());
     mArchive  = archive;
 }
예제 #6
0
 public BackupRestoreVolume(string name, VolumeSource source, BaseArchive archive)
 {
     mName     = name;
     mSource   = source;
     mArchive  = archive;
     mDatabase = new VolumeSnapshotDatabase(archive.GetSnapshotXmlDir());
     Init();
 }
        void MergeSnapshotRevisions( VolumeSnapshotDatabase database, VolumeSource source, BaseArchive archive, int numRevisionsToRemove )
        {
            try
            {
                mDatabase = database;
                mArchive = archive;
                mBusy = true;

                List<VolumeSnapshotRevision> revisionHistory = database.GetRevisionHistory();
                if ( numRevisionsToRemove == revisionHistory.Count )
                {
                    // Need to remove all old revisions, delete everything
                    FileSync.__Log( this, "Merge deleting all revisions" );
                    database.DeleteAllRevisions();
                }
                else
                {
                    // now we know how many revisions to remove, need to rebuild the new first revision.
                    VolumeSnapshotRevision currentRevision = revisionHistory[ numRevisionsToRemove ];
                    VolumeSnapshot currentSnapshot = database.LoadSnapshotRevision( source, currentRevision );

                    FileSync.__Log( this, "Merge is turning revision [" + currentRevision.ToString() + "] into baseline" );
                    TurnSnapshotIntoBaseline( currentSnapshot );

                    // Now go through all existing snapshot .xml files and change any files referencing
                    // a snapshot that has been removed and change it to the current snapshot revision.
                    for ( int revisionNum = numRevisionsToRemove + 1; revisionNum < revisionHistory.Count; ++revisionNum )
                    {
                        VolumeSnapshotRevision incrementalRevision = revisionHistory[ revisionNum ];
                        VolumeSnapshot incrementalSnapshot = database.LoadSnapshotRevision( source, incrementalRevision );

                        FileSync.__Log( this, "Merge is reflecting revision [" + incrementalRevision.ToString() + "] into new baseline [" + currentRevision.ToString()  + "]" );
                        UpdateSnapshotToReflectBaselineRevision( incrementalSnapshot, currentRevision );
                    }

                    // delete old revision data
                    for ( int revisionNum = 0; revisionNum < numRevisionsToRemove; ++revisionNum )
                    {
                        VolumeSnapshotRevision revisionToDelete = revisionHistory[ revisionNum ];
                        FileSync.__Log( this, "Merge is deleting revision [" + revisionToDelete.ToString() + "]" );
                        database.DeleteSnapshotRevision( revisionToDelete );
                    }
                }
            }
            catch ( System.Exception ex )
            {
                FileSync.__LogError( this, "Volume.CheckForExpiredSnapshotRevisions", ex );
            }
            finally
            {
                mBusy = false;
            }
        }
        void MergeSnapshotRevisions(VolumeSnapshotDatabase database, VolumeSource source, BaseArchive archive, int numRevisionsToRemove)
        {
            try
            {
                mDatabase = database;
                mArchive  = archive;
                mBusy     = true;

                List <VolumeSnapshotRevision> revisionHistory = database.GetRevisionHistory();
                if (numRevisionsToRemove == revisionHistory.Count)
                {
                    // Need to remove all old revisions, delete everything
                    FileSync.__Log(this, "Merge deleting all revisions");
                    database.DeleteAllRevisions();
                }
                else
                {
                    // now we know how many revisions to remove, need to rebuild the new first revision.
                    VolumeSnapshotRevision currentRevision = revisionHistory[numRevisionsToRemove];
                    VolumeSnapshot         currentSnapshot = database.LoadSnapshotRevision(source, currentRevision);

                    FileSync.__Log(this, "Merge is turning revision [" + currentRevision.ToString() + "] into baseline");
                    TurnSnapshotIntoBaseline(currentSnapshot);

                    // Now go through all existing snapshot .xml files and change any files referencing
                    // a snapshot that has been removed and change it to the current snapshot revision.
                    for (int revisionNum = numRevisionsToRemove + 1; revisionNum < revisionHistory.Count; ++revisionNum)
                    {
                        VolumeSnapshotRevision incrementalRevision = revisionHistory[revisionNum];
                        VolumeSnapshot         incrementalSnapshot = database.LoadSnapshotRevision(source, incrementalRevision);

                        FileSync.__Log(this, "Merge is reflecting revision [" + incrementalRevision.ToString() + "] into new baseline [" + currentRevision.ToString() + "]");
                        UpdateSnapshotToReflectBaselineRevision(incrementalSnapshot, currentRevision);
                    }

                    // delete old revision data
                    for (int revisionNum = 0; revisionNum < numRevisionsToRemove; ++revisionNum)
                    {
                        VolumeSnapshotRevision revisionToDelete = revisionHistory[revisionNum];
                        FileSync.__Log(this, "Merge is deleting revision [" + revisionToDelete.ToString() + "]");
                        database.DeleteSnapshotRevision(revisionToDelete);
                    }
                }
            }
            catch (System.Exception ex)
            {
                FileSync.__LogError(this, "Volume.CheckForExpiredSnapshotRevisions", ex);
            }
            finally
            {
                mBusy = false;
            }
        }
 public void MergeSnapshotRevisionsByLimitedRevisionCount( VolumeSnapshotDatabase database, VolumeSource source, BaseArchive archive, int maxRevisions )
 {
     // only keep a specific number of revisions
     List<VolumeSnapshotRevision> revisionHistory = database.GetRevisionHistory();
     int numRevisionsToRemove = 0;
     if ( revisionHistory.Count > maxRevisions )
     {
         numRevisionsToRemove = revisionHistory.Count - maxRevisions;
     }
     if ( numRevisionsToRemove > 0 )
     {
         FileSync.__Log( this, "Merge will remove " + numRevisionsToRemove + " revisions" );
         MergeSnapshotRevisions( database, source, archive, numRevisionsToRemove );
     }
     else
         FileSync.__Log( this, "Merge will not remove any revisions" );
 }
        public void MergeSnapshotRevisionsByLimitedRevisionCount(VolumeSnapshotDatabase database, VolumeSource source, BaseArchive archive, int maxRevisions)
        {
            // only keep a specific number of revisions
            List <VolumeSnapshotRevision> revisionHistory = database.GetRevisionHistory();
            int numRevisionsToRemove = 0;

            if (revisionHistory.Count > maxRevisions)
            {
                numRevisionsToRemove = revisionHistory.Count - maxRevisions;
            }
            if (numRevisionsToRemove > 0)
            {
                FileSync.__Log(this, "Merge will remove " + numRevisionsToRemove + " revisions");
                MergeSnapshotRevisions(database, source, archive, numRevisionsToRemove);
            }
            else
            {
                FileSync.__Log(this, "Merge will not remove any revisions");
            }
        }
 public void MergeSnapshotRevisionsByTimeLimit( VolumeSnapshotDatabase database, VolumeSource source, BaseArchive archive, TimeSpan timePeriodToKeep )
 {
     // only keep revisions within a certain time period (e.g. last 6 months)
     List<VolumeSnapshotRevision> revisionHistory = database.GetRevisionHistory();
     int numRevisionsToRemove = 0;
     DateTime cutOffDate = DateTime.Now - timePeriodToKeep;
     foreach ( VolumeSnapshotRevision revision in revisionHistory )
     {
         if ( revision.CreationTime >= cutOffDate )
         {
             break;
         }
         else
             numRevisionsToRemove++;
     }
     if ( numRevisionsToRemove > 0 )
     {
         FileSync.__Log( this, "Merge will remove " + numRevisionsToRemove + " revisions" );
         MergeSnapshotRevisions( database, source, archive, numRevisionsToRemove );
     }
     else
         FileSync.__Log( this, "Merge will not remove any revisions" );
 }