> Some friends of mine need a backup solution that can
> easily handle regular, automated backups from some M$
> Win 2k and Linux workstations as well as an OpenBSD
> 3.8 based Samba file server that I had set up for them
> a while ago. 

I'm a little late to this party, and I apologise if
what I say here has been said already, or ruled out
already.


One of the biggest nuisances with backing up Windows
is that if you just naively walk the file structure
tree, you'll hit files that cause errors that are
very hard to trap.  Some programs such as Karen's
Replicator actually manage to do this but they're in
the minority.

What I discovered earlier this year is that Windows
does in fact have a way of referring to the raw disk
by name (similar to "/dev/hdc1" on unix for example),
which makes it much easier to do a full-disk backup
while a system is running.  Raw C parition would
be \\.\C: for example, and I think the entire drive,
partions, boot blocks and all (eg like /dev/hdc)
is something like \\.\PhysicalDrive0:  (however
I haven't tried that one, only the \\.\C: variant
- see here:
http://www.utexas.edu/its/unix/reference/oracledocs/v92/B10501_01/win.920/a95491/ap_raw.htm
for confirmation)

These names are not usable by all utilities, but
anything in C that does fopen ought to be able
to access them.

Here's a simple program you can use to backup an
entire partition assuming no bad blocks.  It exits
on the first data error which if your disk is good
denotes the end of the partition.  Better handling
of bad blocks is possible, but I didn't need it.
(If I get any, then its time to restore from backup
to a new drive, not time to backup more disk errors!)

Hope this helps.  You might be able to build on
this technique to do something like an scp directly
to a unix (though be careful with the scp protocol 
that you handle >2Gb files properly)

Obviously when you restore the partition, you'll
need to do a windows-style fsck when you reboot as
it will be the equivalent of a crashed machine,
possibly quite an inconsistent one depending on
what was writing to disk during the backup.  This
is why people pay big bucks for professional
backup software.


regards

Graham


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

int main(int argc, char **argv) {
  FILE *input, *output;
  long long bytes = 0LL;
  int c;

  if (argc != 3) {
    fprintf(stderr, "syntax: cp64 \\\\.\\C: D:\\backup.img\n");
    exit(1);
  }
  input = fopen(argv[1], "rb");
  if (input == NULL) {
    fprintf(stderr, "cp64: cannot open input file %s - %s\n", argv[1], 
strerror(errno));
    exit(2);
  }
  output = fopen(argv[2], "wb");
  if (output == NULL) {
    fprintf(stderr, "cp64: cannot open output file %s - %s\n", argv[2], 
strerror(errno));
    exit(3);
  }
  for (;;) {
    c = fgetc(input);
    if (c == EOF) break;
    if (ferror(input)) {
      fprintf(stderr, "Could not read from input (at %lld bytes) - %s\n", 
bytes, strerror(errno));
      exit(4);
    }
    fputc(c, output);
    if (ferror(output)) {
      fprintf(stderr, "Could not write to output (at %lld bytes) - %s\n", 
bytes, strerror(errno));
      exit(5);
    }
    bytes += 1LL;
#ifdef TEST
    if (bytes == 256LL) {
      fprintf(stderr, "Not implemented - only first 256 bytes saved.\n");
      exit(6);
    }
#endif
  }
  fprintf(stderr, "%lld bytes transferred\n", bytes);
  exit(0);
}

Reply via email to