The company now needs to make regular backups of the existing servers and place the backup files in the NAS being used;
For the efficiency of backup, we also need to filter the backup files and exclude some files with suffix names.
The implementation method is as follows:
1. Writing a backup shell file
Edit the backup.sh file where you want to place the shell file
VI Backup. SH
We want to back up the files in the entire directory, except for some files that specify suffix names, so:
Backup main project folder at PM 2:00# by Andrew at 2016/12/2##!/bin//mnt/nasbackup/backup2pm.tar.gz/p roject--exclude=*.ac*--exclude=*.core--exclude=*.err*--exclude=*.fsdb*--exclude=*.ic*--exclude=*.lis*
Here the suffix can be more write some more, there is a good habit of writing notes;
After the finished must give this SH execute permission;
2. Mount the NAS device
Then you will attach the backup to the Linux server, for example, my Nas's IP is 192.168.1.40:
# Mount-o username=admin,password=**********//192.168.1.40/backup/mnt/nasbackup/
You also need to add this to the boot boot, each time the system restarts automatically mounted:
VI /etc/rc.d/rc.local
Add directly to the following.
3. Configuring the Crontab File
The crontab file is executed with a regular command, and the file is located in/etc/crontab, as follows:
SHELL=/bin/BashPATH=/sbin:/bin:/usr/sbin:/usr/Binmailto=Roothome=/# forDetails see Mans 4Crontabs#Example of job definition:#.----------------minute (0-59) # | .-------------Hour (0-23) # | | .----------Day of Month (1-31) # | | | .-------month (1-12) OR jan,feb,mar,apr ... # | | | | .----Day of Week (0-6) (sunday=0 or 7) or SUN,MON,TUE,WED,THU,FRI,Sat# | | | | |# * * * * * * user-nameCommandTo be executed0 * * * root/root/Backup/backup2pm.sh >/dev/null 2>&1 This is done once a day at 2 o'clock noon. backup2pm.sh# */1 * * * * root/root/Backup/test.sh >/dev/null 2>&1 This means doing it every 1 minutes.
The shell that the Linux system automatically backs up