#1145 Issue closed: Support BACKUP_TYPE=incremental/differential also for BACKUP_URL=usb:

Labels: enhancement, fixed / solved / done

jsmeix opened issue at 2017-01-02 12:04:

Neither BACKUP_TYPE 'incremental' nor 'differential'
works with BACKUP_URL=usb:///...
see
https://github.com/rear/rear/issues/1141#issuecomment-269963775

Up to ReaR 2.0
BACKUP_URL=usb:///... only works
with 'nomal' BACKUP_TYPE="".

gdha commented at 2017-01-02 12:43:

@jsmeix By now you know my point of view - do not make of ReaR a backup tool which must support incremental backup. And, as USB work-flow use timestamp directories it would be hard to implement.

jsmeix commented at 2017-01-02 12:50:

I completely agree with your point of view.

I only thought that when ReaR has support for
incremental/differential backup, then it should
work as far as possible with reasonable effort.

Personally I would prefer ReaR has only basic
backup support by its internal backup methods
and leave all advanced backup functionality
to external backup solutions.

If my https://github.com/rear/rear/pull/1146
is o.k. for you we can leave it at this state
also for future ReaR versions.

jsmeix commented at 2017-01-09 12:33:

Perhaps it is possible with low effort to make
BACKUP_TYPE=incremental/differential
also work for BACKUP_URL=usb:

My (currently totally untested) basic idea behind is
that the timestamp directories that are used for
BACKUP_URL=usb implement basically the same
behaviour as NETFS_KEEP_OLD_BACKUP_COPY
so that perhaps it is possible with low effort to use a
single static directory also for BACKUP_URL=usb
in case of BACKUP_TYPE=incremental/differential.

See conf/default.conf why there is no need for NETFS_KEEP_OLD_BACKUP_COPY
together with incremental or differential backup
so that I guess there is perhaps also no need for
timestamp directories for BACKUP_URL=usb
together with incremental or differential backup.

FYI:
Personally I am not so happy that ReaR supports advanced
backup features like BACKUP_TYPE=incremental/differential
but as it is already there I like to get it working well as far as
possible with reasonable effort.

jsmeix commented at 2017-01-12 10:34:

As expected as side-effect of implementing
https://github.com/rear/rear/issues/1160
I made BACKUP_TYPE=incremental/differential
also work for BACKUP_URL=usb
with the following code hack in addition to the
hacks that I described in
https://github.com/rear/rear/issues/1160#issuecomment-272119383

Additional code change
(I run it in a current GitHub master code clone):

# git diff usr/share/rear/prep/NETFS/default/070_set_backup_archive.sh
...
@@ -55,7 +55,7 @@
...
-    Error "BACKUP_TYPE incremental or differential does not work with BACKUP_URL=usb:///..."
+    LogPrint "Note: BACKUP_TYPE incremental or differential needs special setup for BACKUP_URL=usb:///..."
...

Used config
(no multiple backups for BACKUP_TYPE=incremental/differential)

OUTPUT=USB
USB_DEVICE=/dev/disk/by-label/REAR-000
USB_PREFIX="rear/$HOSTNAME/incrementalbackups"
USB_RETAIN_BACKUP_NR=999
BACKUP=NETFS
BACKUP_URL=usb:///dev/disk/by-label/REAR-000
BACKUP_TYPE=incremental
FULLBACKUP_OUTDATED_DAYS=7
FULLBACKUPDAY=Thu

First I run "usr/sbin/rear -d -D mkbackup"
to get an initial full backup of today.

Afterwards I change the config to

FULLBACKUPDAY=Wed

to get incremental backups.

I made two subsequent incremental backups
(I run it in a current GitHub master code clone):

# echo testy1 >/testy1

# usr/sbin/rear -d -D mkbackup

# echo testy2 >/testy2

# usr/sbin/rear -d -D mkbackup

On the REAR-000 medium I get (excerpt)

rear/e205/incrementalbackups
rear/e205/incrementalbackups/kernel
rear/e205/incrementalbackups/rear-e205.log
rear/e205/incrementalbackups/initrd.cgz
rear/e205/incrementalbackups/2017-01-12-1105-F.tar.gz
rear/e205/incrementalbackups/syslinux.cfg
rear/e205/incrementalbackups/2017-01-12-1115-I.tar.gz
rear/e205/incrementalbackups/backup.log
rear/e205/incrementalbackups/2017-01-12-1114-I.tar.gz

and for me "rear recover" works well with that.

@dwerner1
please test how far my above described changes also make
it work for your particular use case and provide feedback here
what goes wrong and/or what is missing for your use case.

dwerner1 commented at 2017-01-12 16:03:

When doing rear -d -D mkbackup with local.conf like

BACKUP=NETFS
OUTPUT=USB
USB_DEVICE=/dev/disk/by-label/REAR-000
USB_PREFIX="rear/$HOSTNAME/fixedbackupdir"
USB_RETAIN_BACKUP_NR=999
USB_DEVICE_PARTED_LABEL=gpt
USB_DEVICE_FILESYSTEM_PERCENTAGE=5
BACKUP_URL=usb:///dev/disk/by-label/REAR-DATA
BACKUP_PROG_EXCLUDE=( ${BACKUP_PROG_EXCLUDE[@]} '/tmp/*' '/temp' '/dev/shm/*' '/mnt/*' )
BACKUP_TYPE=incremental
FULLBACKUP_OUTDATED_DAYS=7
FULLBACKUPDAY=Thu

.. I end up with

ERROR: BACKUP_TYPE incremental or differential does not work with BACKUP_URL=usb:///...

Here are some lines from the log file

++ test incremental = incremental -o differential = incremental
++ set -e -u -o pipefail
++ test NETFS = NETFS -a tar = tar
++ test usb = usb
++ Error 'BACKUP_TYPE incremental or differential does not work with BACKUP_URL=usb:///...'
++ VERBOSE=1
++ LogPrint 'ERROR: BACKUP_TYPE incremental or differential does not work with BACKUP_URL=usb:///...'
++ Log 'ERROR: BACKUP_TYPE incremental or differential does not work with BACKUP_URL=usb:///...'
++ test 1 -gt 0
+++ Stamp

I'm using the current git version and the changes mentioned by @jsmeix in #1160

jsmeix commented at 2017-01-12 16:09:

Additionally you need to use the change mentioned by me in
https://github.com/rear/rear/issues/1145#issuecomment-272129606
;-)

dwerner1 commented at 2017-01-12 16:13:

Uuh, damn, sorry

dwerner1 commented at 2017-01-12 16:42:

OK, that worked out. I made one full and two incremental backups, just the menu labels look like you described in #1160

dwerner1 commented at 2017-01-12 16:49:

That's a really nice state out of my view! Many thanks @jsmeix !

jsmeix commented at 2017-01-12 16:52:

@dwerner1
many thanks for your prompt tests even with my current hacks.

I will sleep over it so that tomorrow I have hopefully good idea
how I can implement it in a backward compatible way...

jsmeix commented at 2017-01-13 14:21:

With
https://github.com/rear/rear/pull/1165
merged this issue is fixed.


[Export of Github issue for rear/rear.]