On Thu, 2003-08-28 at 23:39, Jason Dixon wrote: > Does anyone have a good example of using mt with EOF markers to create > multiple tar archives (one full, multiple incrementals) on a single tape > drive? Please, no suggestions of using dump/restore or Amanda. I'd > like to get this working as-is.
I didn't get any suggestions on this, but I managed to get it working. I'm posting this for archival purposes as a brief HOWTO for backing up data to a tape drive using mt and tar (rather than dump). Obviously, mt is used to perform actions on the tape drive and media. We can use mt to fast-forward between files, records and "marks". In my case, I wished to setup a weekly backup schedule consisting of a full backup on Monday and incremental backups for daily changes on Tuesday-Sunday. Once the final backup is performed on Sunday, the tape will be rewound and ejected. However, since I'm using tar to copy files directly onto the tape, rather than compressing them into a single archive, we need a way to mark the end of one day's backups prior to starting the next day's. To do this, we simply append an EOF to the end of the day's backup. This gives us a way of safely navigating between archives, using the "mt -f /dev/nst0 fsf" command. I'm appending my backup script in the hopes that others may benefit from it. If anyone has questions or suggestions, please don't hesitate to contact me. #!/bin/bash #################################### # Define our vars # You'll want to set DIRS #################################### YESTERDAY=`date +'%d %b %Y'` DIRS="/etc /home /root /var" START=`date +%s` echo "*** Starting Backup - `date` ***" #################################### # Check drive status #################################### if [ `mt -f /dev/nst0 status | grep -c ONLINE` == 0 ]; then echo "Drive is OFFLINE, exiting!" exit 1 fi #################################### # We don't want sockets, # save for later #################################### find $DIRS -type s > /tmp/backup-sockets.list #################################### # Start backups #################################### if [ `date +%u` == 1 ]; then # It's Monday, let's erase and do full backup! mt -f /dev/st0 rewind mt -f /dev/st0 retension mt -f /dev/st0 erase tar cpf /dev/nst0 $DIRS -P -W -X /tmp/backup-sockets.list mt -f /dev/nst0 eof else if [ `date +%u` == 7 ]; then # It's Sunday, let's do an incremental and eject tar cpf /dev/nst0 --newer '$YESTERDAY' $DIRS -P -W -X /tmp/backup-sockets.list mt -f /dev/nst0 eof mt -f /dev/st0 rewoffl else # Let's do an incremental backup tar cpf /dev/nst0 --newer '$YESTERDAY' $DIRS -P -W -X /tmp/backup-sockets.list mt -f /dev/nst0 eof fi echo "*** Backup Complete - `date` ***" #################################### # Compute time and report #################################### END=`date +%s` DIFF=$((FINISH - START)) echo -n "***** Total Run Time: " HRS=`expr $DIFF / 3600` MIN=`expr $DIFF % 3600 / 60` SEC=`expr $DIFF % 3600 % 60` if [ $HRS -gt 0 ]; then echo -n "$HRS hrs " fi if [ $MIN -gt 0 ]; then echo -n "$MIN mins " fi if [ $SEC -gt 0 ]; then echo -n "$SEC secs " fi #################################### # End of Script #################################### -- Jason Dixon, RHCE DixonGroup Consulting http://www.dixongroup.net -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED] https://www.redhat.com/mailman/listinfo/redhat-list