LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   Backing up selected directory... (https://www.linuxquestions.org/questions/linux-enterprise-47/backing-up-selected-directory-204199/)

CRCool75 07-12-2004 03:10 PM

Backing up selected directory...
 
Hello, this is my first post!

I am running Suse Enterprise 8.1 and want to learn how to run an automated backup of selected directories every night. Isn't there some sort of software included for this? I figured there was something equivalent to Windows Backup or something. So far I have looked into the TAR command and cron jobs. Am I on the right track?

Thanks,
CRCool75

Ztyx 07-12-2004 04:24 PM

Yes you are. :) cron is the perfect program in linux for running stuff periodically. tar is the program for putting several files together into one big file. Altough for backuping I guess you also would like to compress your tar-files (since tar only puts the files together). Compressing is usually done with the program gzip in GNU/Linux. How put your backup folders into a compressed file can most easily be shown by an example:
Code:

tar -c folder_one_to_backup folder_two_to_backup | gzip -c > my_backup_file.tar.gz
The line you would like to run periodically by cron can be added in the file /etc/crontab. Also you have the possibility to add a script or program which should run periodically in one of the /etc/cron.[hourly|daily|monthly|weekly] folders.

For info on how to edit the /etc/crontab file you can issue the man -a crontab to look at all (three) man pages which are about crontab (you close each man page by pressing 'q').

Good luck!

/Jens

CRCool75 07-12-2004 05:30 PM

Thanks Ztyx! That was a fast response... I'm really starting to like this place, LOL. Back to my questions... What you said will help me greatly. All I want to do is copy or compress my /serv directory to the tape in my tape drive. Would the following command do the job for one time only?

tar -c /serv /dev/hdd | gzip -c > server_backup.tar.gz

I'm not super sure where the tape drive is located. Incase you have not noticed, I'm very, very new to Linux. If I'm not mistaken, the tape drive would be represented by a folder or file. Am I correct? I wish it was like "My Computer" in MS Windows, but it's not. Thanks again!

CRCool75

stickman 07-12-2004 10:03 PM

Tape drives are usually something like st0, but it depends on your specific model. Try something like:
tar zcf /dev/st0 /serv

To just back it up to a file in another location:
tar zcf /path/to/backup.tgz /serv

You might also consider using the dump command to do your backups. A quick search for backup on Freshmeat gives plenty of other options.

tradewind 07-12-2004 11:40 PM

Hi CRCool75,
Try to use Webmin at www.webmin.com
It's a GUI tool for Linux.
Hope this helps,

CRCool75 07-13-2004 01:02 AM

I am obviously way off as for the format of the command because I am lost now. The following command is evidently incorrect:

tar -c /serv /dev/hdd | gzip -c > server_backup.tar.gz

My intention was to copy the directory of /serv to a compressed file on the tape drive.

Stickman,

I am not sure how my tape drive is listed. I looked under Yast2, and I saw it as /dev/hdd I think, not sure because I am not in front of the server. I'll check out that Freshmeat site. Do you have any recommendations for a free, GUI based backup utility?

Tradewind,

I access the server using Webmin and under "System" I have selected "File System Backup" to create a backup. It will not accept it by saying "Failed to create backup : Filesystems of type REISERFS cannot be backed up by this module". Is there another way of doing this?

Thanks for all your help guys (and gals if there are any).

Ztyx 07-13-2004 06:27 AM

Quote:

Originally posted by CRCool75
I am obviously way off as for the format of the command because I am lost now. The following command is evidently incorrect:

tar -c /serv /dev/hdd | gzip -c > server_backup.tar.gz

My intention was to copy the directory of /serv to a compressed file on the tape drive.

Hi again CRCool75,
Doing the command above reads everything from the /derv folder and the file /dev/hdd. Everything that it reads is compressed and put in the file server_backup.tar.gz. Since I haven't worked with tape backups I don't knopw which device that is, however wether /dev/hdd is a tape or a CD-rom (hdd is usually second CD-ROM) doesn't matter - I don't think you'd like to backup the tape to the harddrive since you want the other way around.

After looking at this page:
http://www.sb.fsu.edu/~xray/Manuals/...l#_Toc40080658
I made a guess that you should do something like
Code:

tar -c /serv > /dev/st0
to backup the /serv folder to your tape drive.

/Jens

stickman 07-13-2004 10:49 AM

Quote:

Originally posted by CRCool75
Stickman,
I am not sure how my tape drive is listed. I looked under Yast2, and I saw it as /dev/hdd I think, not sure because I am not in front of the server. I'll check out that Freshmeat site. Do you have any recommendations for a free, GUI based backup utility?

The basic syntax for creating a backup (whether to a file or a tape) is the same. I wouldn't bother complicating the command with pipes (|) and redirects (>). The basic syntax with gzip compression is:
tar zcf /path/to/backup/file /first/directory /second/directory

The option are:
c - create tar file
z - use gzip compression
f - specify the backup location

For example, to backup /serv to a file in the /backup directory:
tar zcf /backup/today.tgz /serv

To backup the /serv directory to a device like a tape:
tar zcf /dev/st0 /serv

These are really basic examples. You probably need to do a little research on the specific model of your tape drive to see which device it uses then make the appropriate substitution in the command. Try looking at the output of dmesg to see if you recognize anything. If you backup to file, then you probably would want to insert the date into the filename so that you can keep multiples.

CRCool75 07-13-2004 02:46 PM

Ok... I have tried multiple commands and one of them seemed to do something. It just started scrolling all the information down the console window and I could not tell if it was writing to the tape. The drive light just remained on, did not blink what so ever. It is a Seagate Travan 40 and it is the only tape drive in the system. I found a simple command to backup to the default tape drive:

tar -c /srv

That will back up the contents of the /srv directory directly to the default tape drive. It just started scrolling all the crap down the screen again. I believe it is the right crap because I can read some of the contents which are things in that directory. But the question is, is it going to tape?

The particular tape I am using is straight out of the box. It does not need to be formatted does it?

Ztyx 07-13-2004 03:24 PM

No, it is not writing to your tape. The command you do is writing everything to the screen. You have to add the '-f'-flag as stickman said. The -f flag is used to direct the output of the program to somewhere else than the screen.

CRCool75 07-13-2004 07:12 PM

Ahhh... Ok, I will have to look into that tomorrow when I get back in.

CRCool75 07-13-2004 09:14 PM

The following is what I type and the error message I receive now for some reason:

> tar -cf /dev/st0 /srv
tar: /dev/st0: Cannot open: No such device
tar: Error is not recoverable: exiting now

The tape is mounted!

CRCool75 07-13-2004 09:20 PM

How do I know if the data gets put to tape? Is there a command to use that lists the contents of what is on the tape?

CRCool75 07-13-2004 09:21 PM

I am just full of questions! :)

tradewind 07-13-2004 09:57 PM

Quote:

Originally posted by CRCool75
I am just full of questions! :)
Hi CRCCool75,
I've just done a full backup of my system. A SCSI tape is usually recognized as /dev/t0, use the following command to check: ls -l /dev/st*.
Then use the following command:
- If you want to backup a specific directory to tape: tar cpf /dev/st0 -C / your_directory (be careful when typing this command. There is a space between "-C" option and "/" and "your_directory", "-C /" tell tar to change to / directory before doing backup.)
- If you donot want to backup a directory, use the "--exclude=directory" option. For example, if you want to backup all of your system, use this command: tar cpf /dev/st0 -C / --exclude=proc . (the "." at the end of this command tells tar to backup all your systems)
- If you want to check whether the backup is OK: tar dvf /dev/st0
- If you want to list the contents of tape: tar tvf /dev/st0 and tar tvf /dev/st0 > filename.txt if you want to put the output to a file instead of screen.
- If you want to restore from tape: tar xvf /dev/st0
If you want to learn more, try this web: http://ftp.ucr.ac.cr/solrhe/chap29sec305.html
Hope this helps,


All times are GMT -5. The time now is 10:35 PM.