Talk:Full system backup with tar

From ArchWiki
Latest comment: 23 May by Wizetek in topic tar defaults for root and regular users

Serious flaw

tar -xattrs doesn't work: tar -xattrs (create then extract) isn't preserving extended attribute Ttoirrah (talk) 08:42, 19 April 2017 (UTC)Reply

Alternative take

This is an alternate take on the backup command, as a one liner, using Bash brace expansion, the newer zstandard algorithm and generating a sha512 signature:

# eval $(echo bsdtar "--exclude '/"{dev,proc,sys,tmp,run,media,lost+found}"\/*'" --acls --xattrs --zstd -c / \| tee /media_path/backup_name.tar.zst \| sha512sum \> /media_path/backup_name.tar.zst.sha512)

Afterwards the media integrity can be checked with:

# dd if=/media_path/backup_name.tar.zst | sha512sum

I have no experience yet in the Archwiki but I'd like to help with this article, I'll look into it. Rgomez (talk) 10:46, 7 March 2023 (UTC)Reply

This seems to have no benefit apart from "it can be done". The existing script explains the steps piecemeal and is thus easier to understand as well. Closing -- Alad (talk) 16:28, 23 May 2024 (UTC)Reply

tar defaults for root and regular users

Some of the tar options mentioned in the article are default anyway, so specifying them seems redundant.

Current man pages (bsdtar being the one more detailed in this area) show:

  • --acls is the default behavior in c (create) mode for users, and is the default behavior for superuser in x (extract) mode
  • --xattrs is also default in c mode and default in x mode for root
  • -p is for x mode only and is used to restore permissions, attributes, ACLs; it's the default behavior for root; it can be partially overridden by --no-acls, --no-fflags, --no-mac-metadata, --no-xattrs which implies that the reverse equivalents of those are on by default

So, in essence, to create with autodetected (-a) modern compression method

(-v is separated here for visual clarity)

$ tar -v -caf backup.tzst /my/files

and to extract as root user to a specific destination directory path (note that the compression option need not be specified)

# bsdtar -xf backup.tzst -C /

or as unprivileged user (-p is necessary in this case to preserve extra file information)

$ bsdtar -xpf backup.tzst

Wizetek (talk) 13:29, 23 May 2024 (UTC)Reply

I think the options can still be listed for educational purposes. Although, that could be done in a Note instead of appending the options to the command-line. -- Alad (talk) 16:26, 23 May 2024 (UTC)Reply
I agree. Ideally I'd like to see the main command code simplified as much as possible without any extraneous options. Then follows a note which explains that the default invocation actually implies --acls --xattrs and that their application depends on tar operating mode based on user privilege level, and that -p applies only to extraction also based on user access level. Wizetek (talk) 18:50, 23 May 2024 (UTC)Reply