Skip to content

Permission/ownership not preserved as root using patterns #7631

@dominictory

Description

@dominictory

Have you checked borgbackup docs, FAQ, and open GitHub issues?

Yes

Is this a BUG / ISSUE report or a QUESTION?

QUESTION

Your borg version (borg -V).

1.2.3

Operating system (distribution) and version.

Ubuntu 20.04.6 LTS

Hardware / network configuration, and filesystems used.

2x VMs connected. Client device is a Wazuh SIEM instance, to remotely backup automatically to a backup server.

Client with Borg installed -> borg create to remote repo on remote backup server over SSH from client > borg extract on client

How much data is handled by borg?

~ 20MB

Full borg commandline that lead to the problem (leave away excludes and passwords)

As part of the automation script from the documentation, run as root:

borg create \
--filter=AME \
--list \
--stats \
--compression=zstd \
--one-file-system \
$BORG_REPO::'{hostname}-{now}' \
--patterns-from patterns.lst

Extraction of backup repo, run as root:

borg extract $BORG_REPO::repo

Describe the problem you're observing.

After a successful borg create to backup only Wazuh central components, when testing borg extract as root, permissions are not preserved on directories, as well as ownership in child directories.

Backup source:

/:
total 4216708
-rwx------   1 root root       2436 Jun  8 11:51 borg_backup_2.sh
drwxr-xr-x 123 root root      12288 Jun  7 06:05 etc
-rw-r--r--   1 root root       1762 Jun  8 11:53 patterns.lst
drwxr-xr-x  14 root root       4096 Feb 23  2022 usr
drwxr-xr-x  14 root root       4096 May 23  2022 var

patterns.lst:

R /
+ etc/filebeat
+ etc/postfix
+ etc/wazuh-indexer/certs
+ etc/wazuh-indexer/jvm.options
+ etc/wazuh-indexer/jvm.options.d
+ etc/wazuh-indexer/log4j2.properties
+ etc/wazuh-indexer/opensearch.yml
+ etc/wazuh-indexer/opensearch.keystore
+ etc/wazuh-indexer/opensearch-observability
+ etc/wazuh-indexer/opensearch-reports-scheduler
+ etc/wazuh-dashboard/certs
+ etc/wazuh-dashboard/opensearch_dashboards.yml
+ var/ossec/api/configuration
+ var/ossec/etc/client.keys
+ var/ossec/etc/sslmanager*
+ var/ossec/etc/ossec.conf
+ var/ossec/etc/internal_options.conf
+ var/ossec/etc/local_internal_options.conf
+ var/ossec/etc/rules/*.xml
+ var/ossec/etc/decoders/*.xml
+ var/ossec/etc/shared
+ var/ossec/etc/*.pem
+ var/ossec/etc/authd.pass
+ var/ossec/etc/lists
+ var/ossec/queue/agent-groups
+ var/ossec/queue/agentless
+ var/ossec/queue/agents-timestamp
+ var/ossec/queue/fts
+ var/ossec/queue/rids
+ var/ossec/queue/db
+ var/ossec/stats
+ var/ossec/var/db/agents
+ var/ossec/var/multigroups
+ var/ossec/active-response/bin
+ var/ossec/integrations
+ var/ossec/wodles
+ usr/share/wazuh-indexer/plugins/opensearch-security/securityconfig
+ usr/share/wazuh-dashboard/config/opensearch_dashboards.keystore
+ usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml
+ usr/lib/sysctl.d/wazuh-indexer.conf
+ borg_backup_2.sh
+ patterns.lst
- *
- etc/*
- etc/wazuh-indexer/*
- etc/wazuh-dashboard/*
- var/*
- var/ossec/*
- var/ossec/api/*
- var/ossec/etc/*
- var/ossec/queue/*
- var/ossec/var/*
- var/ossec/var/db/*
- var/ossec/active-response/*
- usr/*
- usr/share/*
- usr/share/wazuh-indexer/*
- usr/share/wazuh-indexer/plugins/*
- usr/share/wazuh-indexer/plugins/opensearch-security/*
- usr/share/wazuh-dashboard/*
- usr/share/wazuh-dashboard/config/*
- usr/lib/sysctl.d/*

Extracted repo:

/tmp/borg_restore/:
total 20
-rwx------ 1 root root 2413 Jun  8 11:25 borg_backup_2.sh
drwx------ 6 root root 4096 Jun  8 11:28 etc
-rw-r--r-- 1 root root 1762 Jun  8 11:02 patterns.lst
drwx------ 4 root root 4096 Jun  8 11:28 usr
drwx------ 3 root root 4096 Jun  8 11:28 var

Another example of wrong permissions, as well as ownership:

/tmp/borg_restore/var/ossec/:
total 32
drwx------ 3 root  root  4096 Jun  8 11:28 active-response
drwx------ 3 root  root  4096 Jun  8 11:28 api
drwx------ 6 root  root  4096 Jun  8 11:28 etc
drwxr-x--- 2 root  wazuh 4096 Jun  8 09:02 integrations
drwx------ 6 root  root  4096 Jun  8 11:28 queue
drwxr-x--- 5 wazuh wazuh 4096 May 23  2022 stats
drwx------ 3 root  root  4096 Jun  8 11:28 var
drwxr-x--- 7 root  wazuh 4096 Jun  2 09:27 wodles

/var/ossec/:
total 68
drwxr-x---  3 root  wazuh 4096 May 23  2022 active-response
drwxr-x---  4 root  wazuh 4096 May 23  2022 api
drwxrwx---  7 wazuh wazuh 4096 Jun  8 11:51 etc
drwxr-x---  2 root  wazuh 4096 Jun  8 09:02 integrations
drwxr-x--- 15 root  wazuh 4096 Jun  8 11:51 queue
drwxr-x---  5 wazuh wazuh 4096 May 23  2022 stats
drwxr-x---  9 root  wazuh 4096 Jun  8 11:51 var
drwxr-x---  7 root  wazuh 4096 Jun  2 09:27 wodles

I am thinking this is down to my patterns.lst not adequately backing up metadata of parent directories (/ /etc /var /usr) in order to preserve permissions/ownership. If so, how would I modify patterns.lst to include these parent directories for metadata only, and not their contents other than what I am trying to include above?

Can you reproduce the problem? If so, describe how. If not, describe troubleshooting steps you took before opening the issue.

I run the automated script manually (for testing), then create a folder in /tmp/ to host the extracted repo, all as root. I have tried adding --umask=0022 \ to the script however this did not resolve. Again I believe this is an issue with how I've made my patterns.lst, so am looking for guidance there as above.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions