Esempio n. 1
0
 public SyncVolume( string name, VolumeSource source, BaseArchive archive )
 {
     mName = name;
     mSource = source;
     mDatabase = new VolumeSnapshotDatabase( archive.GetSnapshotXmlDir() );
     mArchive = archive;
 }
Esempio n. 2
0
 public SyncVolume(XmlNode parentNode)
 {
     mName     = PWLib.XmlHelp.GetAttribute(parentNode, "name", "");
     mSource   = VolumeSource.BuildFromXml(parentNode);
     mArchive  = BaseArchive.BuildFromXml(parentNode);
     mDatabase = VolumeSnapshotDatabase.LoadFromXml(parentNode);
 }
Esempio n. 3
0
 public Volume( VolumeEventController eventController, VolumeDescriptor volumeDesc, VolumeSource source, BaseArchive archive )
 {
     mEventController = eventController;
     mVolumeDesc = volumeDesc;
     mBackupRestoreObject = new BackupRestoreVolume( mVolumeDesc.VolumeName, source, archive );
     Init();
 }
Esempio n. 4
0
 public SyncVolume(string name, VolumeSource source, BaseArchive archive)
 {
     mName     = name;
     mSource   = source;
     mDatabase = new VolumeSnapshotDatabase(archive.GetSnapshotXmlDir());
     mArchive  = archive;
 }
Esempio n. 5
0
 public SyncVolume( XmlNode parentNode )
 {
     mName = PWLib.XmlHelp.GetAttribute( parentNode, "name", "" );
     mSource = VolumeSource.BuildFromXml( parentNode );
     mArchive = BaseArchive.BuildFromXml( parentNode );
     mDatabase = VolumeSnapshotDatabase.LoadFromXml( parentNode );
 }
        public bool DoIncrementalBackup(VolumeSnapshot currentSnapshot, VolumeSnapshot mostRecentSnapshot, VolumeSource source, BaseArchive archive, out bool noChangesRequired)
        {
            noChangesRequired = false;
            mSource           = source;
            mArchive          = archive;

            // see if anything's changed from the last one
            currentSnapshot.Root.Revision = mostRecentSnapshot.Root.Revision;
            if (mComparator.CompareSnapshots(mostRecentSnapshot, currentSnapshot, true))
            {
                FileSync.__Log(this, "Incremental comparison complete, changes detected");
                FileSync.__Log(this, "Total file count " + mComparator.Stats.FileCount);
                FileSync.__Log(this, "Total file size " + mComparator.Stats.TotalFileSize);
                FileSync.__Log(this, "New files " + mComparator.Stats.FilesCreated);
                FileSync.__Log(this, "Removed files " + mComparator.Stats.FilesRemoved);
                FileSync.__Log(this, "Changed files " + mComparator.Stats.FilesChanged);
                FileSync.__Log(this, "New directories " + mComparator.Stats.DirectoriesCreated);
                FileSync.__Log(this, "Removed directories " + mComparator.Stats.DirectoriesRemoved);
                FileSync.__Log(this, "Files unchanged " + mComparator.Stats.FilesTheSame);
                FileSync.__Log(this, "Directories unchanged " + mComparator.Stats.DirectoriesTheSame);

                mFileTotalCount        = mComparator.Stats.FileCount;
                mFilesTotalSize        = mComparator.Stats.TotalFileSize;
                mFileRunningCount      = 0;
                mFilesTotalSizeRunning = 0;
                mComparator.CompareSnapshots(mostRecentSnapshot, currentSnapshot, false);
                return(!mOperation.Cancelled);
            }
            else
            {
                FileSync.__Log(this, "Incremental comparison complete, no changes detected");
                noChangesRequired = true;
                return(true);
            }
        }
Esempio n. 7
0
 public BackupRestoreVolume(string name, VolumeSource source, BaseArchive archive)
 {
     mName     = name;
     mSource   = source;
     mArchive  = archive;
     mDatabase = new VolumeSnapshotDatabase(archive.GetSnapshotXmlDir());
     Init();
 }
 private VolumeSnapshotFile( VolumeSnapshot snapshot, VolumeSource source, string relativePath )
 {
     mSnapshot = snapshot;
     mRevision = null;
     mRelativePath = relativePath;
     mFileName = PWLib.Platform.Windows.Path.GetFileName( relativePath );
     mLastModified = source.GetLastWriteTimeUtc( relativePath );
     mFileSize = source.GetFileSize( relativePath );
 }
Esempio n. 9
0
 private VolumeSnapshotFile(VolumeSnapshot snapshot, VolumeSource source, string relativePath)
 {
     mSnapshot     = snapshot;
     mRevision     = null;
     mRelativePath = relativePath;
     mFileName     = PWLib.Platform.Windows.Path.GetFileName(relativePath);
     mLastModified = source.GetLastWriteTimeUtc(relativePath);
     mFileSize     = source.GetFileSize(relativePath);
 }
Esempio n. 10
0
        private VolumeSnapshot( VolumeSource source, XmlNode parentNode )
        {
            mRevision = VolumeSnapshotRevision.Create( PWLib.XmlHelp.GetAttribute( parentNode, VolumeSnapshotXml.XmlRevisionElement, "" ) );
            if ( mRevision == null )
                throw new Exception( "Could not read revision from snapshot xml '" + parentNode.Name + "'" );

            mRoot = VolumeSnapshotDirectory.BuildFromXml( this, PWLib.XmlHelp.GetFirstChildWithName( parentNode, "directory" ) );
            mFileCount = mRoot.CountAllFiles( ref mTotalFileSize );
        }
 public VolumeDescriptor AddNewDescriptor( string volName, string volFilename, VolumeSource source, BaseArchive archive )
 {
     VolumeDescriptor vd = new VolumeDescriptor( mEventController, volName, volFilename, source, archive );
     lock ( mDescriptorList )
     {
         mDescriptorList.Add( vd );
     }
     Config.Active.Save();
     return vd;
 }
        public VolumeDescriptor( VolumeEventController eventController, string volName, string volFilename, VolumeSource source, BaseArchive archive )
        {
            mEventController = eventController;
            mName = volName;
            mVolumeFilename = volFilename;

            mVolume = new Volume( mEventController, this, source, archive );
            ConnectToVolumeEvents( mVolume );
            mIsAvailable = true;
            SaveVolumeData();
        }
Esempio n. 13
0
        private VolumeSnapshot(VolumeSource source, XmlNode parentNode)
        {
            mRevision = VolumeSnapshotRevision.Create(PWLib.XmlHelp.GetAttribute(parentNode, VolumeSnapshotXml.XmlRevisionElement, ""));
            if (mRevision == null)
            {
                throw new Exception("Could not read revision from snapshot xml '" + parentNode.Name + "'");
            }

            mRoot      = VolumeSnapshotDirectory.BuildFromXml(this, PWLib.XmlHelp.GetFirstChildWithName(parentNode, "directory"));
            mFileCount = mRoot.CountAllFiles(ref mTotalFileSize);
        }
 public bool DoFullBackup( VolumeSnapshot currentSnapshot, VolumeSource source, BaseArchive archive )
 {
     mOperation.Reset();
     mFileTotalCount = currentSnapshot.FileCount;
     mFileRunningCount = 0;
     mFilesTotalSize = currentSnapshot.TotalFileSize;
     mFilesTotalSizeRunning = 0;
     mArchive = archive;
     mSource = source;
     return CopyAll( currentSnapshot.Root );
 }
 public bool DoFullBackup(VolumeSnapshot currentSnapshot, VolumeSource source, BaseArchive archive)
 {
     mOperation.Reset();
     mFileTotalCount        = currentSnapshot.FileCount;
     mFileRunningCount      = 0;
     mFilesTotalSize        = currentSnapshot.TotalFileSize;
     mFilesTotalSizeRunning = 0;
     mArchive = archive;
     mSource  = source;
     return(CopyAll(currentSnapshot.Root));
 }
        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 VolumeSnapshot LoadSnapshotRevision(VolumeSource source, VolumeSnapshotRevision revision)
        {
            if (mSnapshotDictionary.ContainsKey(revision))
            {
                return(mSnapshotDictionary[revision]);
            }
            else
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(GetRevisionFileName(revision));

                XmlNode        snapshotXmlNode = PWLib.XmlHelp.GetFirstChildWithName(doc, VolumeSnapshotXml.XmlSnapshotElement);
                VolumeSnapshot snapshot        = VolumeSnapshot.BuildFromXml(source, snapshotXmlNode);
                mSnapshotDictionary.Add(revision, snapshot);
                return(snapshot);
            }
        }
 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 VolumeSnapshot LoadSnapshotRevision( VolumeSource source, VolumeSnapshotRevision revision )
        {
            if ( mSnapshotDictionary.ContainsKey( revision ) )
                return mSnapshotDictionary[ revision ];
            else
            {
                if ( !mSnapshotXmlCache.ContainsKey( revision ) )
                    throw new Exception( "Could not locate snapshot revision '" + revision.ToString() + "' in database" );
                string xmlFragment = mSnapshotXmlCache[ revision ];

                XmlDocument doc = new XmlDocument();
                doc.LoadXml( xmlFragment );

                XmlNode snapshotXmlNode = PWLib.XmlHelp.GetFirstChildWithName( doc, VolumeSnapshotXml.XmlSnapshotElement );
                VolumeSnapshot snapshot = VolumeSnapshot.BuildFromXml( source, snapshotXmlNode );
                mSnapshotDictionary.Add( revision, snapshot );
                return snapshot;
            }
        }
        public VolumeSnapshot LoadSnapshotRevision(VolumeSource source, VolumeSnapshotRevision revision)
        {
            if (mSnapshotDictionary.ContainsKey(revision))
            {
                return(mSnapshotDictionary[revision]);
            }
            else
            {
                if (!mSnapshotXmlCache.ContainsKey(revision))
                {
                    throw new Exception("Could not locate snapshot revision '" + revision.ToString() + "' in database");
                }
                string xmlFragment = mSnapshotXmlCache[revision];

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xmlFragment);

                XmlNode        snapshotXmlNode = PWLib.XmlHelp.GetFirstChildWithName(doc, VolumeSnapshotXml.XmlSnapshotElement);
                VolumeSnapshot snapshot        = VolumeSnapshot.BuildFromXml(source, snapshotXmlNode);
                mSnapshotDictionary.Add(revision, snapshot);
                return(snapshot);
            }
        }
 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" );
 }
        private VolumeSnapshotDirectory( VolumeSnapshot snapshot, VolumeSource source, string relativePath )
        {
            mSnapshot = snapshot;
            mRelativePath = relativePath;
            mName = mRelativePath.Length <= 1 ? "" : PWLib.Platform.Windows.Path.GetLeafName( relativePath );
            mLastModified = source.GetLastWriteTimeUtc( relativePath );// PWLib.Platform.Windows.Directory.GetLastWriteTimeUtc( rootDir );

            foreach ( string filename in source.GetRelativePathFiles( relativePath ) /* PWLib.Platform.Windows.Directory.GetFiles( rootDir ) */ )
            {
                try
                {
                    VolumeSnapshotFile fileEntry = VolumeSnapshotFile.BuildFromSource( mSnapshot, source, filename );
                    mFiles.Add( fileEntry );
                }
                catch ( System.Exception e )
                {
                    FileSync.__LogError( this, "VolumeSnapshotDirectory.BuildFromFileSystem failed on file '" + filename + "'", e );
                }
            }

            foreach ( string subDir in source.GetRelativePathDirectories( relativePath ) )
            {
                try
                {
                    if ( !IsIgnoredDirectoryName( PWLib.Platform.Windows.Path.GetLeafName( subDir ) ) )
                    {
                        VolumeSnapshotDirectory subDirEntry = new VolumeSnapshotDirectory( mSnapshot, source, subDir );
                        mDirectories.Add( subDirEntry );
                    }
                }
                catch ( System.Exception e )
                {
                    FileSync.__LogError( this, "VolumeSnapshotDirectory.BuildFromFileSystem failed on directory '" + subDir + "'", e );
                }
            }
        }
Esempio n. 24
0
        private VolumeSnapshotDirectory(VolumeSnapshot snapshot, VolumeSource source, string relativePath)
        {
            mSnapshot     = snapshot;
            mRelativePath = relativePath;
            mName         = mRelativePath.Length <= 1 ? "" : PWLib.Platform.Windows.Path.GetLeafName(relativePath);
            mLastModified = source.GetLastWriteTimeUtc(relativePath);              // PWLib.Platform.Windows.Directory.GetLastWriteTimeUtc( rootDir );

            foreach (string filename in source.GetRelativePathFiles(relativePath) /* PWLib.Platform.Windows.Directory.GetFiles( rootDir ) */)
            {
                try
                {
                    VolumeSnapshotFile fileEntry = VolumeSnapshotFile.BuildFromSource(mSnapshot, source, filename);
                    mFiles.Add(fileEntry);
                }
                catch (System.Exception e)
                {
                    FileSync.__LogError(this, "VolumeSnapshotDirectory.BuildFromFileSystem failed on file '" + filename + "'", e);
                }
            }

            foreach (string subDir in source.GetRelativePathDirectories(relativePath))
            {
                try
                {
                    if (!IsIgnoredDirectoryName(PWLib.Platform.Windows.Path.GetLeafName(subDir)))
                    {
                        VolumeSnapshotDirectory subDirEntry = new VolumeSnapshotDirectory(mSnapshot, source, subDir);
                        mDirectories.Add(subDirEntry);
                    }
                }
                catch (System.Exception e)
                {
                    FileSync.__LogError(this, "VolumeSnapshotDirectory.BuildFromFileSystem failed on directory '" + subDir + "'", e);
                }
            }
        }
Esempio n. 25
0
 public static VolumeSnapshot BuildFromXml( VolumeSource source, XmlNode parentNode )
 {
     VolumeSnapshot snapshot = new VolumeSnapshot( source, parentNode );
     return snapshot;
 }
Esempio n. 26
0
        public static VolumeSnapshot BuildFromXml(VolumeSource source, XmlNode parentNode)
        {
            VolumeSnapshot snapshot = new VolumeSnapshot(source, parentNode);

            return(snapshot);
        }
Esempio n. 27
0
 void Source_MediaAvailableChanged( VolumeSource source, bool isAvailable )
 {
     mEventController.InvokeVolumeSourceActiveStateChanged( this, isAvailable );
 }
Esempio n. 28
0
        public static VolumeSnapshot BuildFromSource(VolumeSource source)
        {
            VolumeSnapshot snapshot = new VolumeSnapshot(source);

            return(snapshot);
        }
Esempio n. 29
0
 private VolumeSnapshot(VolumeSource source)
 {
     mRevision  = VolumeSnapshotRevision.CreateNew();
     mRoot      = VolumeSnapshotDirectory.BuildFromSource(this, source, "");
     mFileCount = mRoot.CountAllFiles(ref mTotalFileSize);
 }
        public bool DoIncrementalBackup( VolumeSnapshot currentSnapshot, VolumeSnapshot mostRecentSnapshot, VolumeSource source, BaseArchive archive, out bool noChangesRequired )
        {
            noChangesRequired = false;
            mSource = source;
            mArchive = archive;

            // see if anything's changed from the last one
            currentSnapshot.Root.Revision = mostRecentSnapshot.Root.Revision;
            if ( mComparator.CompareSnapshots( mostRecentSnapshot, currentSnapshot, true ) )
            {
                FileSync.__Log( this, "Incremental comparison complete, changes detected" );
                FileSync.__Log( this, "Total file count " + mComparator.Stats.FileCount );
                FileSync.__Log( this, "Total file size " + mComparator.Stats.TotalFileSize );
                FileSync.__Log( this, "New files " + mComparator.Stats.FilesCreated );
                FileSync.__Log( this, "Removed files " + mComparator.Stats.FilesRemoved );
                FileSync.__Log( this, "Changed files " + mComparator.Stats.FilesChanged );
                FileSync.__Log( this, "New directories " + mComparator.Stats.DirectoriesCreated );
                FileSync.__Log( this, "Removed directories " + mComparator.Stats.DirectoriesRemoved );
                FileSync.__Log( this, "Files unchanged " + mComparator.Stats.FilesTheSame );
                FileSync.__Log( this, "Directories unchanged " + mComparator.Stats.DirectoriesTheSame );

                mFileTotalCount = mComparator.Stats.FileCount;
                mFilesTotalSize = mComparator.Stats.TotalFileSize;
                mFileRunningCount = 0;
                mFilesTotalSizeRunning = 0;
                mComparator.CompareSnapshots( mostRecentSnapshot, currentSnapshot, false );
                return !mOperation.Cancelled;
            }
            else
            {
                FileSync.__Log( this, "Incremental comparison complete, no changes detected" );
                noChangesRequired = true;
                return true;
            }
        }
Esempio n. 31
0
        ulong mTotalStoredInThisRevision = 0; // Total unique file size stored in this revision's directory

        #endregion Fields

        #region Constructors

        private VolumeSnapshot( VolumeSource source )
        {
            mRevision = VolumeSnapshotRevision.CreateNew();
            mRoot = VolumeSnapshotDirectory.BuildFromSource( this, source, "" );
            mFileCount = mRoot.CountAllFiles( ref mTotalFileSize );
        }
Esempio n. 32
0
 public static VolumeSnapshot BuildFromSource( VolumeSource source )
 {
     VolumeSnapshot snapshot = new VolumeSnapshot( source );
     return snapshot;
 }
 public static VolumeSnapshotDirectory BuildFromSource( VolumeSnapshot snapshot, VolumeSource source, string relativePath )
 {
     return new VolumeSnapshotDirectory( snapshot, source, relativePath );
 }
        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");
            }
        }
        public VolumeSnapshot LoadSnapshotRevision( VolumeSource source, VolumeSnapshotRevision revision )
        {
            if ( mSnapshotDictionary.ContainsKey( revision ) )
                return mSnapshotDictionary[ revision ];
            else
            {
                XmlDocument doc = new XmlDocument();
                doc.Load( GetRevisionFileName( revision ) );

                XmlNode snapshotXmlNode = PWLib.XmlHelp.GetFirstChildWithName( doc, VolumeSnapshotXml.XmlSnapshotElement );
                VolumeSnapshot snapshot = VolumeSnapshot.BuildFromXml( source, snapshotXmlNode );
                mSnapshotDictionary.Add( revision, snapshot );
                return snapshot;
            }
        }
Esempio n. 37
0
 public static VolumeSnapshotFile BuildFromSource(VolumeSnapshot snapshot, VolumeSource source, string relativePath)
 {
     return(new VolumeSnapshotFile(snapshot, source, relativePath));
 }