digint / btrbk

Tool for creating snapshots and remote backups of btrfs subvolumes
https://digint.ch/btrbk/
GNU General Public License v3.0
1.72k stars 124 forks source link

ERROR: Ambiguous target configuration #417

Open TheNighthawk99 opened 3 years ago

TheNighthawk99 commented 3 years ago

Hello, I installed btrbk on a third server (two others are working seamlessly) and get the error message in subject when (dry)running.

Here below my btrbk.conf file:

#
# Example btrbk configuration file
#
#
# Please refer to the btrbk.conf(5) man-page for a complete
# description of all configuration options.
#
# Note that the options can be overridden per volume/subvolume/target
# in the corresponding sections.
#

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

# Enable stream buffer. Adding a buffer between the sending and
# receiving side is generally a good idea.
# NOTE: If enabled, make sure the "mbuffer" package is installed on
# the target host!
stream_buffer              512m

# 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 autmatically create this directory, and the
# snapshot creation will fail if it is not present.
#
snapshot_dir               _btrbk_snap

# 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       7

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

# Preserve all snapshots for a minimum period of time.
#snapshot_preserve_min      1d

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

# 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

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

# Specify SSH private key for "ssh://" volumes / targets:
ssh_identity               /root/.ssh/id_servername
ssh_user                   root
#ssh_port                   default
#ssh_compression            no
#ssh_cipher_spec            default

# 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. Set this to "after"
# or "each" to make sure the deletion of subvolumes is committed to
# disk when btrbk terminates.
#btrfs_commit_delete        no

timestamp_format           long

#
# Volume section: "volume <volume-directory>"
#
#   <volume-directory>  Directory of a btrfs volume (or subvolume)
#                       containing the subvolume 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>              Backup type, currently only "send-receive".
#   <volume-directory>  Directory of a btrfs volume (or subvolume)
#                       receiving the backups.
#
# NOTE: The parser does not care about indentation, this is only for
# human readability. The options always apply to the last section
# encountered, overriding the corresponding option of the upper
# section. This means that the global options must be set before any
# "volume" section.
#

#
# Example configuration:
#
snapshot_preserve_min   7d
snapshot_preserve       14d 16w 12m

target_preserve_min     no
target_preserve         30d 24w *m

archive_preserve_min    latest
archive_preserve        12m 10y

# Backup to external disk mounted on /mnt/btr_backup
#volume /mnt/btr_pool
  # no action if external disk is not attached
#  snapshot_create  ondemand

#  subvolume  root_gentoo
#    target send-receive      /mnt/btr_backup/_btrbk

#  subvolume  kvm
    # use different retention policy for kvm backups
#    target_preserve          7d 4w
#    target send-receive      /mnt/btr_backup/_btrbk

# Backup to external disk as well as some remote host
volume /mnt/btrfs_ssd
  subvolume  @
    # always create snapshot, even if targets are unreachable
    snapshot_create  always
    #target send-receive      /mnt/btr_backup/_btrbk
    snapshot_name    system
    target           ssh://fileserver_ip/backups/servername

# Backup from remote host, with different naming
#volume ssh://my-remote-host.com/mnt/btr_pool
#  subvolume data_0
#    snapshot_dir             snapshots/btrbk
#    snapshot_name            data_main
#    target send-receive      /mnt/btr_backup/_btrbk/my-remote-host.com

# Resume backups from remote host which runs its own btrbk instance
# creating snapshots for "home" in "/mnt/btr_pool/btrbk_snapshots".
#volume ssh://my-remote-host.com/mnt/btr_pool
#  subvolume home
#    snapshot_dir             btrbk_snapshots
#    snapshot_preserve_min    all
#    snapshot_create          no
#    target send-receive      /mnt/btr_backup/_btrbk/my-remote-host.com

In the file server, I created a folder at /backups/servername to receive backups. This is my /etc/fstab file of host:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
UUID="xxxxxxxx"     /       btrfs     compress=zstd,defaults,ssd,noatime,space_cache,subvol=@ 0 0
UUID="xxxxxxxx"     /home   btrfs     compress=zstd,defaults,ssd,noatime,space_cache,subvol=@home 0 0
/dev/sda1     /boot/efi     vfat     umask=0077     0 1
UUID="xxxxxxxx"     /mnt/btrfs_ssd     btrfs     compress=zstd,defaults,ssd,space_cache,noatime,subvolid=5   0 0

SSH id file has been stored in the fileserver. I can ssh it from the host where btrbk is running. _btrbk_snap directory has been created at /mnt/btrfs_ssd:

name@hostname:$ ls -l /mnt/btrfs_ssd
total 0
drwxr-xr-x 1 root root 200 Oct  2 19:16 @
drwxr-xr-x 1 root root 120 Oct  2 20:29 _btrbk_snap
drwxr-xr-x 1 root root   0 Oct  1 21:23 cdrom
drwxr-xr-x 1 root root  18 Oct  1 21:44 @home
drwxr-xr-x 1 root root 116 Feb  1  2021 run

I could not find any notes about the error. How could I investigate and fix? Thank you.

Details: Ubuntu Server 20.4.3. BTRBK installed through apt-get install btrbk command.

digint commented 3 years ago

I suspect you are using btrbk < 0.28.0 on your server. On earlier versions, the target option requires a target-type, which defaults to send-receive as of btrbk-0.28.0. Try:

target  send-receive   ssh://fileserver_ip/backups/servername

(sorry for the late reply, I've been very busy lately...)