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);
            }
        }
        // This updates cached XML, will still need flushing to disk afterwards in OutputToXml()
        public void SaveSnapshotRevision(VolumeSnapshot snapshot)
        {
            VolumeSnapshotRevision revision = snapshot.Revision;

            if (mSnapshotDictionary.ContainsKey(revision))
            {
                mSnapshotDictionary[revision] = snapshot;
            }
            else
            {
                mSnapshotDictionary.Add(revision, snapshot);
            }

            System.IO.StringWriter stringWriter = new System.IO.StringWriter();
            XmlTextWriter          xmlWriter    = new XmlTextWriter(stringWriter);

            xmlWriter.Formatting = Formatting.Indented;

            snapshot.OutputToXml(xmlWriter);

            string xmlFragment = stringWriter.ToString();

            xmlWriter.Close();
            stringWriter.Close();

            if (mSnapshotXmlCache.ContainsKey(revision))
            {
                mSnapshotXmlCache[revision] = xmlFragment;
            }
            else
            {
                mSnapshotXmlCache.Add(revision, xmlFragment);
            }
        }
        void UpdateSnapshotToReflectBaselineRevision(VolumeSnapshot incrementalSnapshot, VolumeSnapshotRevision newRevision)
        {
            UpdateSnapshotToReflectBaselineRevisionPrivate(incrementalSnapshot.Root, newRevision);

            // save out .xml
            mDatabase.SaveSnapshotRevision(incrementalSnapshot);
        }
        // This updates cached XML, will still need flushing to disk afterwards in OutputToXml()
        public void SaveSnapshotRevision(VolumeSnapshot snapshot)
        {
            VolumeSnapshotRevision revision = snapshot.Revision;

            if (mSnapshotDictionary.ContainsKey(revision))
            {
                mSnapshotDictionary[revision] = snapshot;
            }
            else
            {
                mSnapshotDictionary.Add(revision, snapshot);
            }
            if (!mSnapshotsStored.Contains(revision))
            {
                mSnapshotsStored.Add(revision);
            }

            PWLib.Platform.Windows.Directory.CreateDirectory(mXmlRootDir);
            XmlTextWriter xmlWriter = new XmlTextWriter(GetRevisionFileName(revision), Encoding.Unicode);

            xmlWriter.Formatting = Formatting.Indented;
            xmlWriter.WriteStartDocument();

            snapshot.OutputToXml(xmlWriter);

            xmlWriter.Close();
        }
        public void Restore(VolumeSnapshot snapshot, BaseArchive archive, string onDiskPath)
        {
            mOperation.Reset();

            mFileTotalCount        = 0;
            mFilesTotalSize        = 0;
            mFileRunningCount      = 0;
            mFilesTotalSizeRunning = 0;

            try
            {
                mBusy = true;

                VolumeSnapshotDirectory vsd = snapshot.Root;
                mFileTotalCount = vsd.CountAllFiles(ref mFilesTotalSize);

                if (!mOperation.CanContinue)
                {
                    return;
                }

                int relativePathStartIndex = vsd.RelativePath.LastIndexOf(PWLib.Platform.Windows.Path.DirectorySeparatorChar);
                if (relativePathStartIndex < 0)
                {
                    relativePathStartIndex = 0;
                }
                ProcessDirectoryRestore(vsd, archive, relativePathStartIndex, onDiskPath);
            }
            finally
            {
                mBusy = false;
            }
        }
Esempio n. 6
0
        public bool Restore(VolumeSnapshotRevision revision, string onDiskPath)
        {
            bool success = false;

            mCancelledByUser = false;

            try
            {
                mBusy = true;

                VolumeSnapshot snapshot = mDatabase.LoadSnapshotRevision(mSource, revision);
                mRestoreOperation.Restore(snapshot, mArchive, onDiskPath);
                success = true;
            }
            catch (Exception e)
            {
                success = false;
                FileSync.__LogError(this, "BackupRestoreVolume.Restore", e);
            }
            finally
            {
                mBusy = false;
            }

            return(success);
        }
        public void Restore( VolumeSnapshot snapshot, BaseArchive archive, string onDiskPath )
        {
            mOperation.Reset();

            mFileTotalCount = 0;
            mFilesTotalSize = 0;
            mFileRunningCount = 0;
            mFilesTotalSizeRunning = 0;

            try
            {
                mBusy = true;

                VolumeSnapshotDirectory vsd = snapshot.Root;
                mFileTotalCount = vsd.CountAllFiles( ref mFilesTotalSize );

                if ( !mOperation.CanContinue )
                    return;

                int relativePathStartIndex = vsd.RelativePath.LastIndexOf( PWLib.Platform.Windows.Path.DirectorySeparatorChar );
                if ( relativePathStartIndex < 0 )
                    relativePathStartIndex = 0;
                ProcessDirectoryRestore( vsd, archive, relativePathStartIndex, onDiskPath );
            }
            finally
            {
                mBusy = false;
            }
        }
 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);
 }
 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 TurnSnapshotIntoBaseline(VolumeSnapshot snapshot)
        {
            // iterate over each file in the snapshot. Copy any file that is from an
            // older revision to the current revision and update the .xml.
            List <VolumeSnapshotRevision> revisionsThatCanBeRemoved = new List <VolumeSnapshotRevision>();

            TurnSnapshotIntoBaselinePrivate(snapshot.Root, ref revisionsThatCanBeRemoved);
            snapshot.Root.Revision = snapshot.Root.Snapshot.Revision;

            RemoveOldRevisions(revisionsThatCanBeRemoved);
            mDatabase.SaveSnapshotRevision(snapshot);
        }
        private VolumeSnapshotFile( VolumeSnapshot snapshot, XmlNode node )
        {
            mSnapshot = snapshot;
            mFileName = PWLib.XmlHelp.DirtyString( PWLib.XmlHelp.GetAttribute( node, VolumeSnapshotXml.XmlFilenameElement, "" ) );
            mRelativePath = PWLib.XmlHelp.DirtyString( PWLib.XmlHelp.GetAttribute( node, VolumeSnapshotXml.XmlRelativePathElement, "" ) );
            mRevision = VolumeSnapshotRevision.Create( PWLib.XmlHelp.GetAttribute( node, VolumeSnapshotXml.XmlRevisionElement, "" ) );

            ulong.TryParse( PWLib.XmlHelp.GetAttribute( node, VolumeSnapshotXml.XmlSizeElement, "0" ), out mFileSize );

            long ticks;
            if ( long.TryParse( PWLib.XmlHelp.GetAttribute( node, VolumeSnapshotXml.XmlLastModifiedElement, "0" ), out ticks ) )
                mLastModified = new DateTime( ticks );
        }
Esempio n. 15
0
        private VolumeSnapshotFile(VolumeSnapshot snapshot, XmlNode node)
        {
            mSnapshot     = snapshot;
            mFileName     = PWLib.XmlHelp.DirtyString(PWLib.XmlHelp.GetAttribute(node, VolumeSnapshotXml.XmlFilenameElement, ""));
            mRelativePath = PWLib.XmlHelp.DirtyString(PWLib.XmlHelp.GetAttribute(node, VolumeSnapshotXml.XmlRelativePathElement, ""));
            mRevision     = VolumeSnapshotRevision.Create(PWLib.XmlHelp.GetAttribute(node, VolumeSnapshotXml.XmlRevisionElement, ""));

            ulong.TryParse(PWLib.XmlHelp.GetAttribute(node, VolumeSnapshotXml.XmlSizeElement, "0"), out mFileSize);

            long ticks;

            if (long.TryParse(PWLib.XmlHelp.GetAttribute(node, VolumeSnapshotXml.XmlLastModifiedElement, "0"), out ticks))
            {
                mLastModified = new DateTime(ticks);
            }
        }
        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. 17
0
        private VolumeSnapshotDirectory(VolumeSnapshot snapshot, XmlNode parentNode)
        {
            mSnapshot     = snapshot;
            mName         = PWLib.XmlHelp.DirtyString(PWLib.XmlHelp.GetAttribute(parentNode, VolumeSnapshotXml.XmlNameElement, ""));
            mRelativePath = PWLib.XmlHelp.DirtyString(PWLib.XmlHelp.GetAttribute(parentNode, VolumeSnapshotXml.XmlRelativePathElement, ""));
            mRevision     = VolumeSnapshotRevision.Create(PWLib.XmlHelp.GetAttribute(parentNode, VolumeSnapshotXml.XmlRevisionElement, ""));

            long ticks;

            if (long.TryParse(PWLib.XmlHelp.GetAttribute(parentNode, VolumeSnapshotXml.XmlLastModifiedElement, "0"), out ticks))
            {
                mLastModified = new DateTime(ticks);
            }

            foreach (XmlNode childNode in parentNode.ChildNodes)
            {
                string lowerName = childNode.Name.ToLower();
                if (lowerName == VolumeSnapshotXml.XmlDirectoryElement)                   // Sub directories
                {
                    try
                    {
                        VolumeSnapshotDirectory subDirEntry = new VolumeSnapshotDirectory(mSnapshot, childNode);
                        mDirectories.Add(subDirEntry);
                    }
                    catch (System.Exception e)
                    {
                        FileSync.__LogError(this, "VolumeSnapshotDirectory.BuildFromXml failed in directory '" + mName + "' '" + mRelativePath + "'", e);
                    }
                }
                else if (lowerName == VolumeSnapshotXml.XmlFileElement)                   // Files
                {
                    try
                    {
                        VolumeSnapshotFile fileEntry = VolumeSnapshotFile.BuildFromXml(mSnapshot, childNode);
                        mFiles.Add(fileEntry);
                    }
                    catch (System.Exception e)
                    {
                        FileSync.__LogError(this, "VolumeSnapshotDirectory.BuildFromXml failed in directory on a file '" + mName + "' '" + mRelativePath + "'", e);
                    }
                }
            }
        }
        private VolumeSnapshotDirectory( VolumeSnapshot snapshot, XmlNode parentNode )
        {
            mSnapshot = snapshot;
            mName = PWLib.XmlHelp.DirtyString( PWLib.XmlHelp.GetAttribute( parentNode, VolumeSnapshotXml.XmlNameElement, "" ) );
            mRelativePath = PWLib.XmlHelp.DirtyString( PWLib.XmlHelp.GetAttribute( parentNode, VolumeSnapshotXml.XmlRelativePathElement, "" ) );
            mRevision = VolumeSnapshotRevision.Create( PWLib.XmlHelp.GetAttribute( parentNode, VolumeSnapshotXml.XmlRevisionElement, "" ) );

            long ticks;
            if ( long.TryParse( PWLib.XmlHelp.GetAttribute( parentNode, VolumeSnapshotXml.XmlLastModifiedElement, "0" ), out ticks ) )
                mLastModified = new DateTime( ticks );

            foreach ( XmlNode childNode in parentNode.ChildNodes )
            {
                string lowerName = childNode.Name.ToLower();
                if ( lowerName == VolumeSnapshotXml.XmlDirectoryElement ) // Sub directories
                {
                    try
                    {
                        VolumeSnapshotDirectory subDirEntry = new VolumeSnapshotDirectory( mSnapshot, childNode );
                        mDirectories.Add( subDirEntry );
                    }
                    catch ( System.Exception e )
                    {
                        FileSync.__LogError( this, "VolumeSnapshotDirectory.BuildFromXml failed in directory '" + mName + "' '" + mRelativePath + "'", e );
                    }
                }
                else if ( lowerName == VolumeSnapshotXml.XmlFileElement ) // Files
                {
                    try
                    {
                        VolumeSnapshotFile fileEntry = VolumeSnapshotFile.BuildFromXml( mSnapshot, childNode );
                        mFiles.Add( fileEntry );
                    }
                    catch ( System.Exception e )
                    {
                        FileSync.__LogError( this, "VolumeSnapshotDirectory.BuildFromXml failed in directory on a file '" + mName + "' '" + mRelativePath + "'", e );
                    }
                }
            }
        }
        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);
            }
        }
Esempio n. 20
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);
                }
            }
        }
        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 );
                }
            }
        }
 void Spine_RestoreFinishedWinThread( Volume volume, VolumeSnapshot snapshot )
 {
     ShowBalloonTip( "Restore of " + volume.Descriptor.VolumeName + " finished" );
     mProgressBar.Value = 0;
     MainForm.Instance.SetDefaultStatusText();
     MainForm.Instance.SetTitleText( "", 0 );
     Log.WriteLine( LogType.AppLog | LogType.TextLog | LogType.DebugLog, "Restoration of '" + volume.Descriptor.VolumeName + "' complete" );
     if (RestoreFinished != null)
         RestoreFinished( volume, snapshot );
 }
Esempio n. 23
0
 void Spine_RestoreInitStartedWinThread( Volume volume, VolumeSnapshot snapshot )
 {
     mTreeView.LockInterface( true );
 }
 public void InvokeRestoreStarted( Volume volume, VolumeSnapshot snapshot )
 {
     if ( RestoreStarted != null )
         RestoreStarted( volume, snapshot );
 }
 public void InvokeBackupStarted( Volume volume, VolumeSnapshot snapshot, bool firstBackupOnLoad )
 {
     if ( BackupStarted != null )
         BackupStarted( volume, snapshot, false, firstBackupOnLoad );
 }
Esempio n. 26
0
        public static VolumeSnapshot BuildFromXml(VolumeSource source, XmlNode parentNode)
        {
            VolumeSnapshot snapshot = new VolumeSnapshot(source, parentNode);

            return(snapshot);
        }
        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;
            }
        }
 void spine_RestoreInitStartedWinThread( Volume volume, VolumeSnapshot snapshot )
 {
     //			ShowBalloonTip( "Restore of " + volume.Descriptor.Identifier.Name + " started" );
     MainForm.Instance.SetStatusText("Restoring...");
     MainForm.Instance.SetTitleText( "Restoring", 0 );
     if ( RestoreStarted != null )
         RestoreStarted( volume, snapshot );
 }
 public bool CompareSnapshots(VolumeSnapshot oldDb, VolumeSnapshot newDb, bool countFilesOnly)
 {
     mStats.Reset(!countFilesOnly);
     mOperation.Reset();
     return(ProcessDirectory(oldDb.Root, newDb.Root));
 }
 public static VolumeSnapshotDirectory BuildFromXml( VolumeSnapshot snapshot, XmlNode parentNode )
 {
     VolumeSnapshotDirectory dirEntry = new VolumeSnapshotDirectory( snapshot, parentNode );
     return dirEntry;
 }
 public static VolumeSnapshotDirectory BuildFromSource( VolumeSnapshot snapshot, VolumeSource source, string relativePath )
 {
     return new VolumeSnapshotDirectory( snapshot, source, relativePath );
 }
 public static VolumeSnapshotFile BuildFromXml( VolumeSnapshot snapshot, XmlNode node )
 {
     return new VolumeSnapshotFile( snapshot, node );
 }
Esempio n. 33
0
        public static VolumeSnapshotDirectory BuildFromXml(VolumeSnapshot snapshot, XmlNode parentNode)
        {
            VolumeSnapshotDirectory dirEntry = new VolumeSnapshotDirectory(snapshot, parentNode);

            return(dirEntry);
        }
 void Spine_RestoreFinished( Volume volume, VolumeSnapshot snapshot )
 {
     mInvokeControl.Invoke( new VolumeRestoreHandler( Spine_RestoreFinishedWinThread ), volume, snapshot );
 }
 void Spine_BackupFinished( Volume volume, VolumeSnapshot snapshot, bool snapshotHasBeenSaved, bool firstBackupOnLoad )
 {
     mVolumeListView.Refresh();
 }
        void TurnSnapshotIntoBaseline( VolumeSnapshot snapshot )
        {
            // iterate over each file in the snapshot. Copy any file that is from an
            // older revision to the current revision and update the .xml.
            List<VolumeSnapshotRevision> revisionsThatCanBeRemoved = new List<VolumeSnapshotRevision>();
            TurnSnapshotIntoBaselinePrivate( snapshot.Root, ref revisionsThatCanBeRemoved );
            snapshot.Root.Revision = snapshot.Root.Snapshot.Revision;

            RemoveOldRevisions( revisionsThatCanBeRemoved );
            mDatabase.SaveSnapshotRevision( snapshot );
        }
 void spine_RestoreInitStarted( Volume volume, VolumeSnapshot snapshot )
 {
     mInvokeControl.Invoke( new VolumeRestoreHandler( spine_RestoreInitStartedWinThread ), volume, snapshot );
 }
        void UpdateSnapshotToReflectBaselineRevision( VolumeSnapshot incrementalSnapshot, VolumeSnapshotRevision newRevision )
        {
            UpdateSnapshotToReflectBaselineRevisionPrivate( incrementalSnapshot.Root, newRevision );

            // save out .xml
            mDatabase.SaveSnapshotRevision( incrementalSnapshot );
        }
Esempio n. 39
0
        public static VolumeSnapshot BuildFromSource(VolumeSource source)
        {
            VolumeSnapshot snapshot = new VolumeSnapshot(source);

            return(snapshot);
        }
 void Spine_RestoreFinished( Volume volume, VolumeSnapshot snapshot )
 {
     mLabel.Text = mCancelledByUser ? "Transfer cancelled" : "Transfer complete";
     mButtonNext.Enabled = true;
 }
 public void InvokeBackupFinished( Volume volume, VolumeSnapshot snapshot, bool snapshotHasBeenSaved, bool firstBackupOnLoad )
 {
     if ( BackupFinished != null )
         BackupFinished( volume, snapshot, snapshotHasBeenSaved, firstBackupOnLoad );
 }
Esempio n. 42
0
 public static VolumeSnapshot BuildFromXml( VolumeSource source, XmlNode parentNode )
 {
     VolumeSnapshot snapshot = new VolumeSnapshot( source, parentNode );
     return snapshot;
 }
 public void InvokeRestoreProgress( Volume volume, VolumeSnapshot snapshot, ulong fileNum, ulong fileCount, ulong bytesTranferred, ulong totalBytes )
 {
     if ( RestoreProgress != null )
         RestoreProgress( volume, snapshot, fileNum, fileCount, bytesTranferred, totalBytes );
 }
Esempio n. 44
0
 public static VolumeSnapshot BuildFromSource( VolumeSource source )
 {
     VolumeSnapshot snapshot = new VolumeSnapshot( source );
     return snapshot;
 }
Esempio n. 45
0
 void Spine_RestoreFinishedWinThread( Volume volume, VolumeSnapshot snapshot )
 {
     mTreeView.LockInterface( false );
 }
Esempio n. 46
0
 public static VolumeSnapshotFile BuildFromSource(VolumeSnapshot snapshot, VolumeSource source, string relativePath)
 {
     return(new VolumeSnapshotFile(snapshot, source, relativePath));
 }
Esempio n. 47
0
 void Spine_BackupFinishedWinThread( Volume volume, VolumeSnapshot snapshot, bool snapshotHasBeenSaved, bool firstBackupOnLoad )
 {
     mTreeView.SetVolumeAsBusy( volume.Descriptor, false );
 }
Esempio n. 48
0
 public static VolumeSnapshotFile BuildFromXml(VolumeSnapshot snapshot, XmlNode node)
 {
     return(new VolumeSnapshotFile(snapshot, node));
 }
Esempio n. 49
0
        public bool DoBackup(ref bool outputToXmlRequired)
        {
            VolumeSnapshot currentSnapshot   = null;
            bool           backupSuccess     = false;
            bool           noChangesRequired = false;

            outputToXmlRequired = false;
            mCancelledByUser    = false;

            try
            {
                mBusy = true;

                FileSync.__Log(this, "Building standing on disk snapshot...");

                // Take a snapshot of the volume as it stands on disk
                currentSnapshot = VolumeSnapshot.BuildFromSource(mSource);

                if (!currentSnapshot.Empty)
                {
                    FileSync.__Log(this, "Snapshot built, " + currentSnapshot.FileCount + " files found");

                    VolumeSnapshotRevision mostRecentRevision = mDatabase.GetMostRecentRevision();

                    // Compare to previous snapshot
                    if (mostRecentRevision != null)
                    {
                        FileSync.__Log(this, "Starting incremental backup, " + mDatabase.GetRevisionHistory().Count
                                       + " revisions existing [Most recent: " + mostRecentRevision.ToString() + "]");

                        // Only do an incremental backup to backup whats changed since last full snapshot
                        VolumeSnapshot mostRecentSnapshot = mDatabase.LoadSnapshotRevision(mSource, mostRecentRevision);
                        backupSuccess = mBackupOperation.DoIncrementalBackup(currentSnapshot, mostRecentSnapshot, mSource, mArchive, out noChangesRequired);

                        FileSync.__Log(this, "Incremental backup " + (backupSuccess ? "completed successfully" : "failed")
                                       + " " + (noChangesRequired ? "no changes required" : "changes detected"));
                    }
                    else
                    {
                        FileSync.__Log(this, "Starting full initial backup");

                        // Brand new volume backup, do a full backup of the volume
                        backupSuccess = mBackupOperation.DoFullBackup(currentSnapshot, mSource, mArchive);

                        FileSync.__Log(this, "Full backup " + (backupSuccess ? "completed successfully" : "failed"));
                    }

                    if (backupSuccess)
                    {
                        if (!noChangesRequired)
                        {
                            FileSync.__Log(this, "Saving snapshot revision file [" + currentSnapshot.Revision.ToString() + "]");

                            mDatabase.SaveSnapshotRevision(currentSnapshot);
                            outputToXmlRequired = true;

                            FileSync.__Log(this, "Snapshot file saved");
                        }
                        else
                        {
                            FileSync.__Log(this, "No changes required, not saving revision [" + currentSnapshot.Revision.ToString() + "]");
                        }
                    }
                    else
                    {
                        FileSync.__Log(this, "Backup failed, deleting temporary files for revision [" + currentSnapshot.Revision.ToString() + "]");
                        mDatabase.DeleteSnapshotRevision(currentSnapshot.Revision);                           // remove half-copied data
                        mArchive.DeleteRevision(currentSnapshot.Revision);
                        outputToXmlRequired = true;
                    }
                }
                else
                {
                    FileSync.__Log(this, "Built snapshot is empty, aborting backup");
                }
            }
            catch (Exception e)
            {
                backupSuccess = false;
                FileSync.__LogError(this, "BackupRestoreVolume.DoBackup", e);

                if (currentSnapshot != null)
                {
                    FileSync.__Log(this, "Backup failed due to exception caught, deleting temporary files for revision [" + currentSnapshot.Revision.ToString() + "]");
                    mDatabase.DeleteSnapshotRevision(currentSnapshot.Revision);                       // remove half-copied data
                    mArchive.DeleteRevision(currentSnapshot.Revision);
                }
                outputToXmlRequired = true;
            }
            finally
            {
                mBusy = false;
            }

            return(backupSuccess);
        }
 void Spine_BackupFileFinished( Volume volume, VolumeSnapshot snapshot, ulong fileNum, ulong fileCount, ulong bytesTranferred, ulong totalBytes )
 {
     mInvokeControl.Invoke( new VolumeBackupProgressHandler( Spine_BackupFileFinishedWinThread ), volume, snapshot, fileNum, fileCount, bytesTranferred, totalBytes );
 }
 public bool CompareSnapshots( VolumeSnapshot oldDb, VolumeSnapshot newDb, bool countFilesOnly )
 {
     mStats.Reset( !countFilesOnly );
     mOperation.Reset();
     return ProcessDirectory( oldDb.Root, newDb.Root );
 }
        // This updates cached XML, will still need flushing to disk afterwards in OutputToXml()
        public void SaveSnapshotRevision( VolumeSnapshot snapshot )
        {
            VolumeSnapshotRevision revision = snapshot.Revision;
            if ( mSnapshotDictionary.ContainsKey( revision ) )
                mSnapshotDictionary[ revision ] = snapshot;
            else
                mSnapshotDictionary.Add( revision, snapshot );
            if ( !mSnapshotsStored.Contains( revision ) )
                mSnapshotsStored.Add( revision );

            PWLib.Platform.Windows.Directory.CreateDirectory( mXmlRootDir );
            XmlTextWriter xmlWriter = new XmlTextWriter( GetRevisionFileName( revision ), Encoding.Unicode );
            xmlWriter.Formatting = Formatting.Indented;
            xmlWriter.WriteStartDocument();

            snapshot.OutputToXml( xmlWriter );

            xmlWriter.Close();
        }