[ Script ] How To Backup and Restore Directory Permissions on Linux Machines

Python 0 Comments

There is many ways to backup and restore on Linux machines, but when you have a specific need you must use some sort of scripting, don’t rely on tools because i think this get you stuck in thinking that there no other way to do the thing you need to do.

The requirement was that we need a script to backup and restore Linux directory permissions until a certain depth, for example, we need to backup permissions of the source directory /root and three directories beneath it.

Using the script is straightforward: you need to update 4 variable:

sourceDir: The source directory to use as a backup source
extractOut: The file that will store the backed up permission. This file is also used as the source of the permissions to restore
op: The operation to execute: B= Backup / R= Restore
level: The directory depth level to scan

With some minor tweaks it can also be used on Windows machines.

The script backup and restore standard Linux permissions, it doesn’t handle ACL entries nor SElinux context.

You can get it here on my Github repo.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

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.