Hervé Werner
2015-06-08 11:26:11 UTC
Hello
I found out that in some cases rsnapshot's lockfile is not removed which makes it issue a warning the next time it runs.
Here is a demonstration :
I'm using the following configuration file :
config file :
config_version 1.2
snapshot_root /media/LV_BACKUP/rsnapshot/
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_logger /usr/bin/logger
retain alpha 3
retain beta 2
retain gamma 2
verbose 5
loglevel 3
lockfile /var/run/rsnapshot.pid
one_fs 1
link_dest 1
use_lazy_deletes 1
backup /tmp/test localhost
I then execute rsnapshot twice :
$ sudo rsnapshot alpha
require Lchown
Lchown module not found
Setting locale to POSIX "C"
echo 32014 > /var/run/rsnapshot.pid
mkdir -m 0755 -p /media/LV_BACKUP/rsnapshot/alpha.0/
/usr/bin/rsync -avx --delete --numeric-ids --relative --delete-excluded \
/tmp/test/ /media/LV_BACKUP/rsnapshot/alpha.0/localhost
sending incremental file list
created directory /media/LV_BACKUP/rsnapshot/alpha.0/localhost
/tmp/
/tmp/test/
/tmp/test/env.txt
/tmp/test/install-dep.txt
/tmp/test/install-dep.txt2
sent 38,800 bytes received 152 bytes 77,904.00 bytes/sec
total size is 38,490 speedup is 0.99
rsync succeeded
touch /media/LV_BACKUP/rsnapshot/alpha.0/
/usr/bin/logger -p user.info -t rsnapshot[32014] /usr/local/bin/rsnapshot \
alpha: completed successfully
$ sudo rsnapshot alpha
require Lchown
Lchown module not found
Setting locale to POSIX "C"
WARNING: Removing stale lockfile /var/run/rsnapshot.pid
/usr/bin/logger -p user.err -t rsnapshot[32020] WARNING: Removing stale \
lockfile /var/run/rsnapshot.pid
WARNING: About to remove lockfile /var/run/rsnapshot.pid which belongs to a different process: 32014 (this is OK if it's a stale lock)
rm -f /var/run/rsnapshot.pid
echo 32020 > /var/run/rsnapshot.pid
mv /media/LV_BACKUP/rsnapshot/alpha.0/ /media/LV_BACKUP/rsnapshot/alpha.1/
mkdir -m 0755 -p /media/LV_BACKUP/rsnapshot/alpha.0/
/usr/bin/rsync -avx --delete --numeric-ids --relative --delete-excluded \
--link-dest=/media/LV_BACKUP/rsnapshot/alpha.1/localhost \
/tmp/test/ /media/LV_BACKUP/rsnapshot/alpha.0/localhost
sending incremental file list
created directory /media/LV_BACKUP/rsnapshot/alpha.0/localhost
sent 171 bytes received 85 bytes 512.00 bytes/sec
total size is 38,490 speedup is 150.35
rsync succeeded
touch /media/LV_BACKUP/rsnapshot/alpha.0/
/usr/bin/logger -p user.err -t rsnapshot[32020] WARNING: \
/usr/local/bin/rsnapshot alpha: completed, but with some warnings
Actually according to the source code this behavioir happens when using the lazy_delete feature as the lockfile seem to only be removed when a _delete directory exists :
## code sub handle_interval
# if use_lazy_delete is on, delete the _delete.$$ directory
# we just check for the directory, it will have been created or not depending on the value of use_lazy_delete
if (-d "$config_vars{'snapshot_root'}/_delete.$$") {
# this is the last thing to do here, and it can take quite a while.
# we remove the lockfile here since this delete shouldn't block other rsnapshot jobs from running
remove_lockfile();
So I think rsnapshot should either create a dumb _delete directory if there is no previous backup to clean or add something like remove_lockfile() if ($use_lazy_deletes).
dud
I found out that in some cases rsnapshot's lockfile is not removed which makes it issue a warning the next time it runs.
Here is a demonstration :
I'm using the following configuration file :
config file :
config_version 1.2
snapshot_root /media/LV_BACKUP/rsnapshot/
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_logger /usr/bin/logger
retain alpha 3
retain beta 2
retain gamma 2
verbose 5
loglevel 3
lockfile /var/run/rsnapshot.pid
one_fs 1
link_dest 1
use_lazy_deletes 1
backup /tmp/test localhost
I then execute rsnapshot twice :
$ sudo rsnapshot alpha
require Lchown
Lchown module not found
Setting locale to POSIX "C"
echo 32014 > /var/run/rsnapshot.pid
mkdir -m 0755 -p /media/LV_BACKUP/rsnapshot/alpha.0/
/usr/bin/rsync -avx --delete --numeric-ids --relative --delete-excluded \
/tmp/test/ /media/LV_BACKUP/rsnapshot/alpha.0/localhost
sending incremental file list
created directory /media/LV_BACKUP/rsnapshot/alpha.0/localhost
/tmp/
/tmp/test/
/tmp/test/env.txt
/tmp/test/install-dep.txt
/tmp/test/install-dep.txt2
sent 38,800 bytes received 152 bytes 77,904.00 bytes/sec
total size is 38,490 speedup is 0.99
rsync succeeded
touch /media/LV_BACKUP/rsnapshot/alpha.0/
/usr/bin/logger -p user.info -t rsnapshot[32014] /usr/local/bin/rsnapshot \
alpha: completed successfully
$ sudo rsnapshot alpha
require Lchown
Lchown module not found
Setting locale to POSIX "C"
WARNING: Removing stale lockfile /var/run/rsnapshot.pid
/usr/bin/logger -p user.err -t rsnapshot[32020] WARNING: Removing stale \
lockfile /var/run/rsnapshot.pid
WARNING: About to remove lockfile /var/run/rsnapshot.pid which belongs to a different process: 32014 (this is OK if it's a stale lock)
rm -f /var/run/rsnapshot.pid
echo 32020 > /var/run/rsnapshot.pid
mv /media/LV_BACKUP/rsnapshot/alpha.0/ /media/LV_BACKUP/rsnapshot/alpha.1/
mkdir -m 0755 -p /media/LV_BACKUP/rsnapshot/alpha.0/
/usr/bin/rsync -avx --delete --numeric-ids --relative --delete-excluded \
--link-dest=/media/LV_BACKUP/rsnapshot/alpha.1/localhost \
/tmp/test/ /media/LV_BACKUP/rsnapshot/alpha.0/localhost
sending incremental file list
created directory /media/LV_BACKUP/rsnapshot/alpha.0/localhost
sent 171 bytes received 85 bytes 512.00 bytes/sec
total size is 38,490 speedup is 150.35
rsync succeeded
touch /media/LV_BACKUP/rsnapshot/alpha.0/
/usr/bin/logger -p user.err -t rsnapshot[32020] WARNING: \
/usr/local/bin/rsnapshot alpha: completed, but with some warnings
Actually according to the source code this behavioir happens when using the lazy_delete feature as the lockfile seem to only be removed when a _delete directory exists :
## code sub handle_interval
# if use_lazy_delete is on, delete the _delete.$$ directory
# we just check for the directory, it will have been created or not depending on the value of use_lazy_delete
if (-d "$config_vars{'snapshot_root'}/_delete.$$") {
# this is the last thing to do here, and it can take quite a while.
# we remove the lockfile here since this delete shouldn't block other rsnapshot jobs from running
remove_lockfile();
So I think rsnapshot should either create a dumb _delete directory if there is no previous backup to clean or add something like remove_lockfile() if ($use_lazy_deletes).
dud