A shell script for automatic backup we agreed that you can use the shell script with crones to perform regular work. To make a regular work, on UNIX is the use of crones. -------------------------------------------------- ----------------------------- First let's take to study how to back up the system. To back up the system, it is nothing more than some compression tools. On many UNIX systems, TAR and GZIP are DE FACTO data exchange criteria. We can often see some tar.gz or tgz files, these files, called Tarball. Of course, you can also compress the compression tool with BZIP2, ZIP, etc., does not have to be limited to GZIP. But TAR cooperates with GZIP is the most common and most convenient way. To compress the information we want, back up, you can carry out Tar and Gzip. There are many ways, the most commonly used instructions are the following: TAR-C File / Dir ... | Gzip -9> xxxx.tar.gz You can also do it: Tar -R file / dir ... -f xxxx.tar gzip -9 xxxx.tar or tar -r file / dir ... -f xxxx.tar gzip -9
-------------------------------------------------- ------------------------------ If you have many machines, you can take advantage of one of the lighter internal network hosts. , As a main backup host. Automatically perform backups all machines, then use NFS / CODA / Samba such as NFS / CODA / Samba, put the backup information in this backup machine, then charge backup data, then you will make a backup in the machine. . Here is the illustration of the entire system backup scheme. Before you do, let's take it, those in the system are backup, those who are not needed. -------------------------------------------------- ------------------------------ New Backup #! / Bin / sh hostname = `Hostname` DIRS =" / ETC / VAR / YOUR_IMPORTANT_DIRECTORY "Backup =" / Tmp / $ hostname.tgz "NFS =" / mnt / nfs "TAR-C $ DIRS | GZIP -9> $ BACKUP MV -F $ BACKUP $ NFS ------------------ -------------------------------------------------- ---------------------- Script: Collect_Backup #! / Bin / sh nfs = "/ mnt / nfs" backup = "/ backup" MV in the backup host -f $ nfs / *. TGZ $ backup here, you cannot put all backups directly / mnt / NFS, which is dangerous. In case any machine accidentally deletes / mnt / nfs all content, then the backup will disappear. Therefore, you need to move / MNT / NFS to a directory where the backup host is accessible. -------------------------------------------------- ------------------------------ When these individual scrips are tested, we will put them in crontab. Find your crontab, its location may be on / var / spool / cron / crontabs / root, / etc / crontab, / var / cron / tabs / root. Select one of the following to join (see you regular time): slonware: / var / spool / cron / crontabs / root 01 * * * * / full_backup_script_path / backup 1> / dev / null 2> / dev / null # Hourly (too fire a little) 30 16 * * * / full_backup_script_path / backup 1> / dev / null 2> / dev / null # 1:30 per day, backup 30 16 * * 0 / full_backup_script_path / backup 1> / DEV / NULL 2> / dev / null # 6:30 on Monday 16:30 0 5 1 * * / full_backup_script_path / backup 1> / dev / null 2> / dev / null # monthly No. 5: 0 redhat / debian: / etc / crontab redhat can put backup in /etc/cron.Hourly, /etc/cron.daily, /etc/cron.monthly.