I want to backup only incremental with rsync

Asked 2 years ago, Updated 2 years ago, 70 views

running environment:
CentOS 7.3

I would like to back up only increments with rsync for generation management.

I'm planning to back up as follows.

Base (total amount to be backed up)
|
L01 (back up files with changes only)
L02 (back up files with changes only)
・
・
・
L07 (back up files with changes only)

For example, the full base directory (the destination directory) contains the following backup contents

hoge01.txt
hoge02.txt
hoge03.txt
01 has hoge04.txt (no base in 01)
Hoge0.txt5 exists in 02 (01 and base do not exist in 02)

Problems you are having

rsync-av --link-dest and

hoge01.txt
hoge02.txt
hoge03.txt
hoge04.txt
hoge0.txt5

This behavior is not intended to be

In short, we want to manage generations, so if we back up like above, we will run out of disk space.

Is it possible to back up only increments with rsync?

If possible, could you tell me the options?
Also, if rsync cannot provide backup, is there an alternative?

Please let me know.

centos rsync

2022-09-30 19:50

2 Answers

In a nutshell, if rsync --dest-link is working as intended, I think you are saving on your own disk space.
You should then be able to use the commands below to confirm that disk savings have been made.

Using rsync's --dest-link option, if the target file is the same as the previous backup, the two files are "hardlinked."
(Strictly speaking, time stamps and permissions must be the same for hardlinks, but I don't think it's going to be a big problem under this rsync --dest-link situation.)

The two "hard-linked" files look like separate files, and each file entry actually points to a single entity on the disk.
You can verify that the i-node numbers displayed are the same by specifying the -i option in ls.

"The example of the question, ""hoge01.txt,"" should be hard-linked, so

"
$ls-li01/hoge.txt02/hoge.txt
42467349-rw-rw-r--6 hidezz hidezz671 June 1200:1401/hoge.txt
42467349-rw-rw-r--6 hidezz hidezz671 June 1200:1402/hoge.txt

should display the same i-node number (42467349)

Other rough ways to distinguish
If two directories are dued together, one or the other's proprietary disk space should appear as small as the hard link.

$du-d0-h0102
14M01
404K02

If you du for each directory separately, it should show a different size than the one above.

$du-d0-h01
14M01
$ du-d0-h02
14M02

Since the -dest-link option is generated by the hard link, can I use it remotely?
Instead of backing up the differences locally, we would like to consolidate them into backup servers.

Wouldn't it be better to bring the local file to the remote side and then use --dest-link to create a generation backup on the remote side machine?


in an environment where you can connect ssh from a remote machine to a local machine On remote machines

$rsync-avH local machine: /home/data//home/localmachine/data/--dest-link=... 

I think it's easy to do things like that.In my case, I actually use this method.

If ssh connections are only allowed from the local machine or you want to execute commands from the local machine, split them into two

$rsync-avH/home/data/remote machine:/home/localmachinemp/data/
$ ssh remote machine "rsync-avH/home/localmachinemp/data//home/localmachine/data --dest-link=..."

I have a feeling thatThe second rsync may be run periodically with cron or something like that.
In this case, you will need more /home/localmachinemp, which will consume the disk.


2022-09-30 19:50

If you search the web for "rsync increment", for example, the following pages will be hit.

Rsync only!6 backup methods for files [command example]

Incremental Backup with Generation Management

–link-dest scripted to always point to the previous backup to implement incremental backups with generation management.

#!/bin/bash

BASEDIR="/test/dst"#Backup destination parent directory
LATESTBKUP=$(ls$BASEDIR|grep backup-|tail-n1)# Directory name of the most recent backup

rsync-avh --link-dest="$BASEDIR/$LATESTBKUP"/test/src/"/test/dst/backup-$(date+%Y%m%d-%H%M%S)"


2022-09-30 19:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.