Rsnapshot for backup?

Gerd - I created a 1st draft wiki page for rsnapshot.

https://wiki.ipfire.org/addons/rsnapshot

2 Likes

Here is an example commit message Adolf created two years ago:

https://git.ipfire.org/?p=ipfire-2.x.git;a=commit;h=7300386babf8304c28ac5937a95f39555e647226

Suggestions for changes to /etc/rsnapshot.conf:

no_create_root

I almost filled my primary drive when I left the below disabled.

# If no_create_root is enabled, rsnapshot will not automatically create the
# snapshot_root directory. This is particularly useful if you are backing
# up to removable media, such as a FireWire or USB drive.
#
no_create_root	1				# <- changed

cmd_du

Uncomment so user can use the /usr/bin/rsnapshot du command.

# Uncomment this to specify the path to "du" for disk usage checks.
# If you have an older version of "du", you may also want to check the
# "du_args" parameter below.
#
cmd_du		/usr/bin/du		# <- changed

cmd_rsnapshot_diff

Uncomment so user can use the /usr/bin/rsnapshot-diff command.

# Uncomment this to specify the path to rsnapshot-diff.
#
cmd_rsnapshot_diff	/usr/bin/rsnapshot-diff		# <- changed

lockfile

The lockfile should be changed from /var/run/rsnapshot.pid to /run/rsnapshot.pid

# If enabled, rsnapshot will write a lockfile to prevent two instances
# from running simultaneously (and messing up the snapshot_root).
# If you enable this, make sure the lockfile directory is not world
# writable. Otherwise anyone can prevent the program from running.
#
lockfile	/run/rsnapshot.pid		# <- changed

link_dest

Rsync added link-dest about 20 years ago. It uses hard links to save space on the backup drive. This should be enabled.

# If your version of rsync supports --link-dest, consider enabling this.
# This is the best way to support special files (FIFOs, etc) cross-platform.
# The default is 0 (off).
#
link_dest	1					# <- changed
1 Like

I guess this is because if you do not mount the backup disk, with that option not activated rsnapshot would create a new backup directory on the main root file system, correct?

1 Like

Correct.

With no_create_root disabled, rsnapshot will create the snapshot_root directory.

For me the snapshot_root directory is:

# All snapshots will be stored under this root directory.
#
snapshot_root	/mnt/hdd/rsnapshot/

And when I started:

#no_create_root	1

Since I did not have a mounted drive (yet), all of the backup was located on the primary drive at /mnt/hdd/rsnapshot.

I didn’t know this type of thing could happen!

I learned this the hard way as well. If the external HD cannot be mounted for some reason, the main file system could get filled up easily. I have this snippet of code in my backup scripts, to make sure the external disk is always correctly mounted before proceeding:

if [ ! -d "$DEST/lost+found" ]; then
     echo -e "`date +%H:%M:%S` USB Disk could not be mounted, aborting!\n"
     exit 1
fi

this relies on the presence of lost+found which is in the host directory only if an external file system (EXT3 or EXT4, not FAT) is correctly mounted inside the root file system. If the lost+found is not there, the script aborts before running the backup.

As side note, besides the problem of filling up the main disk, you might think you have a backup. Until you find out, when you need to do the restore, that your backup is gone together with the original file system because it was never saved on the external disk in the first place. USB disks can be quite capricious and this would happen more often than one might think.

I did something similar. This what I am trying:

MOUNTPOINT=/mnt/hdd							# drive - 1TB
. . .
if ! /usr/bin/mountpoint -q $MOUNTPOINT ; then
	/usr/bin/mount -v /dev/sdb1 $MOUNTPOINT
fi
1 Like

Gerd - here are some other suggestions.

Change the ./configure from this:

+###############################################################################
+# Installation Details
+###############################################################################
+
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
+	@$(PREBUILD)
+	@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
+	cd $(DIR_APP) && \
+		./configure \
+		--prefix=/usr \
+		--sysconfdir=/etc
+		--mandir=/usr/share/man \
+
+	cd $(DIR_APP) && make $(MAKETUNING)

change to this:

./configure        \
--prefix=/usr      \
--sysconfdir=/etc  \
--bindir=/usr/bin

and remove the --mandir=/usr/share/man line. man pages are not included.

Sorry all of the isn’t in one post. I am reading about rsnapshot and learning! Hopefully one of the Devs will review and post on the Dev mailing list.

EDIT: removed incorrect items above

1 Like

I never knew about the mountpoint utility. Thanks @jon. About your test, I think it should be repeated after the mount command as well. A disk or an adapter can fail and then the mount command will fail as well. At least, it happened to me several times.

I would do something like this

/usr/bin/mount -v /dev/sdb1 $MOUNTPOINT || exit 1

the or statement || gets evaluated only if the preceding command fails.

1 Like

personally i do my backups on the nfs share of my nas.

Ciao Gerd

1 Like

Check out my new patch in the list…

Ciao Gerd

would adding a wui to it be beneficial? something like webrsnapshot

I posted the new version of it in dev mailing list

Ciao Gerd

it looks like it needs something called Mojolicious so I doubt it would be accepted (this is my opinion).

https://github.com/dobrevg/webrsnapshot/blob/master/INSTALL.md#requirements

More info about webrsnapshot (in German):

1 Like

Hi !

i think no because before you have to implement Mojolicious framework where webrsnapshot is based on…

Ciao Gerd