The company's Linux server uses a common desktop and lacks a disaster recovery mechanism. The company stores a large amount of data on this server. Once a fault occurs, the consequences are unimaginable. Therefore, it is necessary to effectively back up important data of this machine. After several days of data collection, I finally compiled my own Linux script to implement a complete monthly backup and daily Incremental backup, the packaged file contains a detailed list of files backed up on the current day for future recovery. Incremental Backup stores data within 90, and data earlier than 90 will be automatically deleted. All backup files are saved locally and automatically backed up to another host through the network. The detailed script content is as follows:#! /Bin/sh Date = 'date + % F-% H' Host = "192.168.16.17" Id = "admin" PW = "123456" Ftpdir = "days" Baktime = 'date -- date = '90 days ago '+ % Y-% m-% d' If ['date + % d' = '1'] Then Filename = "linux$.tar.gz" Basedir = "/mnt/SMB/bak/monthly" ZL = "" Bakdir = "/data/Arca/work/Linux" Else Filename = "bak1_date.tar.gz" Basedir = "/mnt/SMB/bak/days" ZL = "-T/tmp/filelist-2.daily" Bakdir = "" Fi Find/data/Arca/work/Linux/-type F-mtime-1-print> $ bakdir/filelist. Daily CAT/tmp/filelist. Daily | grep '/. [C. H] $'>/tmp/filelist-2.daily # Echo $ baktime # Tar-n' $ baktime' zcvf $ basedir/$ filename $ bakdir Tar $ zl-czvf $ {basedir}/$ filename $ {bakdir} # Starting FTP to Send File CD $ basedir FTP-N> "$ basedir"/"$ FILENAME". log 2> & 1 <EOC Open $ host User $ ID $ pw Binary CD $ ftpdir Mput $ filename Bye EOC Test-e bak1_baktime.tar.gz & Rm-F Bak $ baktime * | ECHO not fonud this files Store the file in/etc/cron. In the daily directory, this directory is the directory that the system regularly runs. This script runs once a day and completes the current score on the first day of each month. Incremental backup is performed on other dates. some files are not important, so select only. c. h file for backup. This script is not complete yet. If the script cannot be sent to the remote host, you cannot determine it. I will modify the problem below. After a simple modification, the script can synchronize the local data and Master/Slave Data. It is widely used. |