Skip to content

Backup and restore file permissions

When you are, for example, migrating to another server, you may want to preserve the ownership and permissions for those files. Here’s how you can do it.

First, install acl. Here’s the command for Debian-based systems:

apt-get install acl

After that, run the following command to write the permission data for [directory] to permissions.txt:

getfacl -R [directory] > permissions.txt

To restore the permissions, run:

setfacl --restore=permissions.txt


Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.