-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup-firefox.sh
More file actions
executable file
·31 lines (24 loc) · 933 Bytes
/
Copy pathbackup-firefox.sh
File metadata and controls
executable file
·31 lines (24 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Backup Firefox settings for each profile.
# 2020-10-04
echo "Firefox backup"
TargetDir="$1"
[ -z "$TargetDir" ] && { echo "Please provide a path for the files."; exit 1; }
FirefoxDir="$HOME/.mozilla/firefox"
if [[ ! -d "$FirefoxDir" ]]; then
echo "- No Firefox settings found"
exit 0
fi
# Find paths to all existing profiles
IFS=$'\n' # needed to avoid splitting strings with spaces
grep Path "$FirefoxDir/profiles.ini" | cut -d= -f2 | while IFS= read -r Profile; do
#echo "Profile $Profile"
mkdir -p "$TargetDir/$Profile"
# Bookmarks
LastFile=$(find "$FirefoxDir/$Profile/bookmarkbackups/" -type f | sort | tail -1)
[ "$LastFile" ] && cp -p "$LastFile" "$TargetDir/$Profile" || echo "No bookmarks found for profile $Profile."
# Extensions
find "$FirefoxDir/$Profile/extensions" -maxdepth 1 -name "*.xpi" -exec basename {} \; | sort > "$TargetDir/$Profile/extensions.txt"
done
unset IFS
exit 0