Skip to content

Instantly share code, notes, and snippets.

@adrienjoly
Created July 15, 2025 17:37
Show Gist options
  • Save adrienjoly/ec10c511538e8492553d1bc17b8311a1 to your computer and use it in GitHub Desktop.
Save adrienjoly/ec10c511538e8492553d1bc17b8311a1 to your computer and use it in GitHub Desktop.
a bash/terminal script to copy all files of a volume (with their attributes) to a local directory. tested on macOS.
# Usage:\
# $ cd /Volumes
# $ ls
# $ ./backup-disk.sh "Archives musique"
set -e # stop the script if any command fails with a non-zero exit code
echo Backup "$1" to "~/Downloads/BluRay/$1/" ...
cp -Rpnf "./$1" "$HOME/Downloads/BluRay/"
chmod -R +w "$HOME/Downloads/BluRay/$1"
cd "$HOME/Downloads/BluRay/$1/"
ls -R > "$1.txt"
cp "$1.txt" ..
cd /Volumes
say "backup is finished"
drutil eject external
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment