Last active
May 23, 2018 06:43
-
-
Save silviaclaire/34c30194590eed78308195d18beed245 to your computer and use it in GitHub Desktop.
Linux: Backup directory structure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# (https://superuser.com/questions/1095234/bash-script-to-backup-and-restore-directory-structure) | |
# create a tar file <Directory_Structure.tar> of the directory structure | |
# and a list of files <File_List.txt> | |
# in PWD | |
HomeDir=$(pwd) | |
BackupDIR="Backup" # Change here | |
TarFileName="$HomeDir/Directory_Structure.tar" | |
ListFileName="$HomeDir/File_List.txt" | |
cd "$BackupDIR" | |
tar -cf "$TarFileName" --no-recursion --files-from <(find . -type d) | |
find . -type f -exec echo touch \"{}\" \; > "$ListFileName" | |
gzip --best "$ListFileName" "$TarFileName" # this to compress them |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
tar -zxf Directory_Structure.tar.gz | |
zcat File_List.txt.gz | /bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment