How to use differential and Incremental Backup in linux
Source: Internet
Author: User
Article Title: how to use differential and Incremental Backup in linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Running properly in redhat Linux 7.2
Mybackup. sh
Code:
#! /Bin/sh
Umount/mnt/bak
Mount/dev/sdb1/mnt/bak
If ['date + % d' = 01] # complete backup on the first day of every month
Then
Bakdir = "/mnt/bak/daybak/month/" 'date + % m % d'
Zl = "" # complete backup
Else
Bakdir = "/mnt/bak/daybak/" 'date + % d'
Zl = "-N" 'date + % Y-% m-01 00:00:01 '; # differential backup
# Zl = "-N" 'date-d-1 day + % Y-% m-% d 00:00:01 '# daily Incremental Backup
Fi
Tmpbakdir =$ {bakdir} tmp
Rm-rf $ {tmpbakdir}
Mkdir $ {tmpbakdir}
Tar "$ {zl}"-czf $ {tmpbakdir}/www. tgz/var/www/html
Tar "$ {zl}"-czf $ {tmpbakdir}/etc. tgz/etc
Tar "$ {zl}"-czf $ {tmpbakdir}/mysql. tgz/var/lib/mysql
Tar "$ {zl}"-czf $ {tmpbakdir}/home. tgz/home
Tar "$ {zl}"-czf $ {tmpbakdir}/name. tgz/var/name
Rm-rf $ bakdir
Mv $ tmpbakdir $ bakdir
Umount/mnt/bak
Set mybackup. place sh in/etc/cron. in daly, you can achieve monthly cyclic differential/Incremental backup to facilitate data recovery. I used differential backup. If you want to save space, you can use daily total backups. However, it will be troublesome to restore data, in addition, you can easily change the above script to weekly loop.
The other method of Incremental backup is to use the find command, for example, to back up only the files modified one day ago.
Code:
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