0

Im currently trying to create a "shallow" backup of my whole filesystem, meaning that I should be able to somehow backup the current full filesystem structure, including mainly file ownerships and permissions, without the actual files contents for a fast "snapshot" of the filesystem in case I mess up the permissions at some later point, so I would be able to restore the ownerships and permissions recursively in such case.

The main objectives are:

  • The backup is very small in size since its only containing metadata (preferrably only ownership and permissions attributes)
  • The backup is fast(er) to create compared to an actual backup
  • The backup should be able to be restored 1:1 to the original target (ignoring new files missing from the backup)

Would this be possible e.g. using rsync, tar or similar tools?

A similar question was asked here.

However, Im looking for a full/comprehensive solution to the problem and objectives described.

Sinipelto
  • 137
  • 8

1 Answers1

0

I can try to answer the question myself. This answer probably requires corrections.

To backup the a directory, attributes only recursively and preservatively, and using tar to store the resulting structure in a single file, one can use:

[sudo] cp -rT --attributes-only --preserve=mode,ownership /path/to/source /path/to/dest
[sudo] tar -C / -cf /path/to/backup.tar /path/to/dest

And to restore, use reverse approach:

[sudo] tar -C / -xf /path/to/backup.tar
[sudo] cp -rT --attributes-only --preserve=mode,ownership /path/to/dest /path/to/source

Root/sudo required to preserve

Sinipelto
  • 137
  • 8