Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: duplicated instance when /etc/crontab set to run hourly at 00 minute #588

Open
janusn opened this issue Apr 25, 2024 · 1 comment

Comments

@janusn
Copy link

janusn commented Apr 25, 2024

If I set /etc/cron.hourIy/btrbk to run at 00 min each hour, btrbk reports an error through email with the following error every midnight.

It won't have a problem if I run it at other schedule such as min 22 each hour.

The email looks like the following:

Subject: btrbk <$hostname> ERROR - Another instance of btrbk is running, no backup tasks performed!
Content: Running btrbk: ERROR (code=3): Another instance of btrbk is running, no backup tasks performed!

DETAIL:

Running btrbk

++ 'btrbk' '-c' '/etc/btrbk/btrbk.conf' 'run'
. ERROR: Failed to take lock (another btrbk instance is running): /var/lock/btrbk.lock

ERROR (code=3): Another instance of btrbk is running, no backup tasks performed!

The content of the file /etc/btrbk/btrbk.conf:

#
# btrbk configuration file
#
#
# Please refer to the btrbk.conf(5) man-page for a complete
# description of all configuration options.
# For more examples, see README.md included with this package.
#
#   btrbk.conf(5): <https://digint.ch/btrbk/doc/btrbk.conf.5.html>
#   README.md:     <https://digint.ch/btrbk/doc/readme.html>
#
# Note that the options can be overridden per volume/subvolume/target
# in the corresponding sections.
#


# Enable transaction log
transaction_log            /var/log/btrbk.log

# timestamp
timestamp_format           long

# Specify SSH private key for remote connections
ssh_identity               /etc/btrbk/ssh/id_ecdsa
ssh_user                   nuc13

# Use sudo if btrbk or lsbtr is run by regular user
#backend_local_user         btrfs-progs-sudo
backend_remote             btrfs-progs-sudo

######################################################################################################
# Ignoring errors on the remote system.
# It does not guarantee the backups can be restored but we don't have a choice when backing up to DSM7
######################################################################################################
compat_remote              ignore_receive_errors

# Enable stream buffer. Adding a buffer between the sending and
# receiving side is generally a good idea.
# NOTE: If enabled, make sure to install the "mbuffer" package!
stream_buffer              256m

# Directory in which the btrfs snapshots are created. Relative to
# <volume-directory> of the volume section.
# If not set, the snapshots are created in <volume-directory>.
#
# If you want to set a custom name for the snapshot (and backups),
# use the "snapshot_name" option within the subvolume section.
#
# NOTE: btrbk does not automatically create this directory, and the
# snapshot creation will fail if it is not present.
#
snapshot_dir               _btrbk_snapshots

# Always create snapshots. Set this to "ondemand" to only create
# snapshots if the target volume is reachable. Set this to "no" if
# snapshot creation is done by another instance of btrbk.
snapshot_create            always

# Perform incremental backups (set to "strict" if you want to prevent
# creation of non-incremental backups if no parent is found).
incremental                yes

# Specify after what time (in full hours after midnight) backups/
# snapshots are considered as a daily backup/snapshot
preserve_hour_of_day       0

# Specify on which day of week weekly/monthly backups are to be
# preserved.
preserve_day_of_week       sunday

# Preserve all snapshots for a minimum period of time.
snapshot_preserve_min      48h

# Retention policy for the source snapshots.
#snapshot_preserve          <NN>h <NN>d <NN>w <NN>m <NN>y
snapshot_preserve          72h 14d 10w

# Preserve all backup targets for a minimum period of time.
target_preserve_min        no

# Retention policy for backup targets:
#target_preserve            <NN>h <NN>d <NN>w <NN>m <NN>y
target_preserve            14d 10w

# Retention policy for archives ("btrbk archive" command):
#archive_preserve_min       no
#archive_preserve           <NN>h <NN>d <NN>w <NN>m <NN>y

# Enable compression for remote btrfs send/receive operations:
#stream_compress            no
#stream_compress_level      default
#stream_compress_threads    default

# Enable lock file support: Ensures that only one instance of btrbk
# can be run at a time.
lockfile                   /var/lock/btrbk.lock

# Don't wait for transaction commit on deletion. Enable this to make
# sure the deletion of subvolumes is committed to disk when btrbk
# terminates.
#btrfs_commit_delete no


#
# Volume section (optional): "volume <volume-directory>"
#
#   <volume-directory>  Base path within a btrfs filesystem
#                       containing the subvolumes to be backuped
#                       (usually the mount-point of a btrfs filesystem
#                       mounted with subvolid=5 option).
#
# Subvolume section: "subvolume <subvolume-name>"
#
#   <subvolume-name>    Subvolume to be backuped, relative to
#                       <volume-directory> in volume section.
#
# Target section: "target <type> <volume-directory>"
#
#   <type>              (optional) type, defaults to "send-receive".
#   <volume-directory>  Directory within a btrfs filesystem
#                       receiving the backups.
#
# NOTE: The parser does not care about indentation, this is only for
# human readability. All options apply to the last section
# encountered, overriding the corresponding option of the upper
# section. This means that the global options must be set on top,
# before any "volume", "subvolume" or "target section.
#


volume /mnt/btr_pool
	subvolume rootfs
		snapshot_dir _btrbk_snapshots/rootfs
		target ssh://10.27.0.40/volume2/nuc13_backups/rootfs

	subvolume docker
		snapshot_dir _btrbk_snapshots/docker
		target ssh://10.27.0.40/volume2/nuc13_backups/docker

#	subvolume docker/nextcloud/data
#		snapshot_dir _btrbk_snapshots/nextcloud_data
#		snapshot_name nextcloud_data
#		target ssh://10.27.0.40/volume2/nuc13_backups/nextcloud/data

	subvolume docker/nc/mariadb/config/databases
		snapshot_dir _btrbk_snapshots/nextcloud_mariadb_databases
		snapshot_name nextcloud_mariadb_databases
		target ssh://10.27.0.40/volume2/nuc13_backups/nextcloud/mariadb_databases
@Meneth32
Copy link

If you installed btrbk using apt on a debian-like system, there's probably a systemd service running. To check, run:
sudo systemctl status btrbk

In that case, disable either your cronjob or the service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants