tags:

views:

74

answers:

4

Hi,

I'm thinking of a Backup Utility as my next project idea, but I don't really know where to start or how the backups should be made.

Can anyone shine some light on what methods of archiving backups and restoring etc. is done.

Thanks

A: 
  • Are you planning on backing up sector-by-sector, or file-by-file?
  • Will your backup run as an Admin (access to all files) or as a User (access to only some files)?
  • How do you safeguard Admin-level information now stored in your backup file from User-level viewers?
  • Must your target medium have adequete space for the backup (large network drive) or will the backup be able to span several media? (CDROMs)
  • In the latter case, how will you deal with individual files bigger than a single target media?
  • Will you always do a full backup (everything, always) or an incremental (just what changes since the last backup) or a differential (just what changes since the last full backup)?
James Curran
+1  A: 

Read through this Wikipedia Article - Backup and make sure you understand everything in it.

The simplest backup utility would be to allow a user to select a source folder, and destination folder, and just copying it across. (as that is all a backup is essentially).

But you will need some recursive folder calls to backup each folder inside folders.

LnDCobra
+2  A: 

One of easier methods would be:

  1. Allow user to select target folder and destination, and destination type (Zip, copy, etc)
  2. Copy/Compress the files and sub folders inside target folder to destination

If you just want to copy files, then you can use DirectoryInfo and FilesInfo to obtain directory, files, and perform FileCopy, FileMove, etc...

If you want to compress files at destination, then you can use the existing library like 7z, which has codes for C# as well.

Holystream
A: 

To start with, I don't believe I've seen any namespace or classes in the .NET Framework specifically designed for backup/archive/restore activities. If anyone knows of any, well, enlighten us please!

At its simplest, backing up files is simply copying files from one location to another. Let's say that you have source code that you would like to maintain a backup of, and it changes a bit day by day. You could create a small console app that would simply copy all the files in the target folders to an external drive, overwriting any files that had changed since the last copy operation, and adding any new files and folders to the destination. Then use a Scheduled Task to run the utility once per day at a time when the computer is not being otherwise used -- or at least when the source is not being edited.

There are lots of methods and classes in the System.IO namespace that will make this relatively easy to do.

Some useful classes in the IO namespace are:

  • Directory provides static methods for creating, moving and enumerating through directories and subdirecties
  • DirectoryInfo is a class exposing properties of Folders/Directories
  • File provides static methods for files
  • FileInfo is a class exposing properties of files.

Here's a code sample that would give you an array of all the top-level folders just under the root of the C: drive:

string[] d = Directory.GetDirectories(@"C\", "*.*", SearchOption.TopDirectoryOnly);
DirectoryInfo[] di = new DirectoryInfo[d.Length];
for (int x = 0; x < d.Length; x++)
{
    di[x] = new DirectoryInfo(d[x]);
}
Cyberherbalist