This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Cygrunsrv and backups


hi all,

--Chuck wrote:
> Dunno...but you might look into rsync via ssh; both have been ported to 
> cygwin and work well.

i ended up not looking into rsync because i found lots of documentation on
the web (including on the cygwin mailinglist) on how to use mt / tar. i have
compiled my findings into the attached document; hopefully other backup
newbies will find it helpful. er, cygwiners please bare in mind it is very
basic as this is my first shot at UNIX backups!! 

my script is now working but there are some points i would like to clarify.
I marked those as QUESTION, if someone can help me with them i would be
immensely grateful. Also, let me know if anything is incorrect / just plain
wrong.

thanks.

marco

backing up using cygwin and dat tapes
------------------------

there are several steps required:

STEP 1. Mount the device. Windows sees the dat tape as "//./tape0", and you
can mount it by issuing:

$ mount -f -s -b "//./tape0" "/dev/st0"

or 

$ mount -f -s -b "//./tape0" "/dev/nst0"

this tells the cygwin utilities that there is a tape device on the
system. The first version of the command lets the drive rewind the
media automatically; the second version is called no-rewind, and this
means the tape has to be rewound manually (notice the "n" on
/dev/Nst0). this is the preferred mode.

QUESTION: once you mount it, it stays permanently mounted. If you try
to unmount it you get an error message. how do you unmount it?

STEP 2. although most drives automatically rewind tapes on insertion, you
should make sure the tape is at the beginning by rewinding it manually. you
do
that with mt (magnetic tape):

$ mt -f "/dev/nst0" rewind

if there is no tape on the drive, this will result on an error
message, similar to:

mt: /dev/nst0: Permission denied

If you create a backup script, it is a good idea to test for this at
the beginning of it.

STEP 3. you can skip this step if you are using a new tape or if you are
going to overwrite the
existing data. 

if you want to append data to the tape it must be positioned at the right
place before 
you start writing. there are two ways of doing this:

$ mt -f "/dev/nst0" fsf 1

this command forward skips the tape by n files, being n in this case 1.

if you don't know how many files are on the tape, you can move directly to
the end:

$ mt -f "/dev/nst0" eod

do NOT confuse "eod" (end of data) with eot. see mt's man page for
details. 

QUESTION: what happens if my backup is bigger than one tape?

STEP 4. write the file with the tar command:

$ tar -zcf /dev/nst0 /home

here, I am backing up all home directories. Check the tar man page for
details of how to use tar.

if there are more files to write, keep on issuing new tar commands and they
will be stored sequentially on the tape. (by "more files" we mean more
tarballs, as each tarball can have many files).

at this point it is perhaps a good idea to add the backed up file to the
label of the tape. this makes things easier when testing / recovering.

STEP 5. make sure the backup was successful. 

STEP 5.1. first rewind the tape:
 
$ mt -f /dev/nst0 bsf 1

where 1 is the number of files you recently backed up. You can also
rewind the tape completely (see STEP 2).

STEP 5.2. when you are at the right position check the contents of the
tarball:

$ tar -ztf /dev/nst0

If tar displays the correct list of files on the screen the backup was
successful. Repeat the process for each tarball you created.

STEP 6. when finished testing, rewind the tape (STEP 2)

STEP 7. Eject the tape:

$ mt -f /dev/nst0 offline

the backup is completed. to restore the data, move to the right
position on the tape (STEP 3), and use tar:

$ tar -zxf /dev/nst0 

this restores the data onto the current folder.

NOTES: 

- It is usual to have all of these steps on a shell script. there are
  many examples of these on the web.

- as far as I am aware, all of the following steps apply to LINUX (and
  other GNU based unices) as well, with the exception of first step
  (you don't mount the media).

- you can use hardware compression on the drive, through mt's
  options. If you do so, do not compress the data again with the "z"
  option of tar.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]