Skip to content

Commit fadc2f9

Browse files
committed
Add scripts to quickly backup/restore important items of the ~/Library/Application Support folder
1 parent 82e81dd commit fadc2f9

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

.bin/backup-application-support

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
BACKUP_FOLDER="$HOME/Dropbox/Backups/Application Support"
4+
APPLICATIONS=(
5+
"Farrago"
6+
"Fission"
7+
"Loopback"
8+
"Audio Hijack"
9+
"Flux"
10+
"com.operasoftware.Opera"
11+
"com.tinyapp.TablePlus"
12+
"obs-studio"
13+
)
14+
15+
datestamp=$(date +%Y-%m-%d)
16+
directory="${BACKUP_FOLDER}/${datestamp}"
17+
18+
test -d "$directory" || mkdir -p "$directory"
19+
20+
cd "$HOME/Library/Application Support"
21+
22+
for application in "${APPLICATIONS[@]}"; do
23+
echo "Archiving settings of ${application} to ${directory}"
24+
tar cjf "${directory}/${application}.tar.bz2" "$application"
25+
done
26+

.bin/restore-application-support

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
BACKUP_FOLDER="$HOME/Dropbox/Backups/Application Support"
4+
last=$(ls "$BACKUP_FOLDER" | sort | tail -n1)
5+
datestamp="${1:-$last}"
6+
7+
cd "$HOME/Library/Application Support"
8+
IFS=$'\n'
9+
for app in $(find "${BACKUP_FOLDER}/${datestamp}" -name "*tar.bz2"); do
10+
target="$(basename -s .tar.bz2 "$app")"
11+
echo "$target"
12+
test -d "$target" \
13+
&& echo mv "$target" "${target}__old_$(date +%s)"
14+
echo tar xjf "$app"
15+
done
16+

0 commit comments

Comments
 (0)