The shell that the Linux system automatically backs up

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.