I'm trying to Backup Browser Bookmarks to the Users Document folder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-30-2020 07:38 AM
# This is a script I found for Chrome, it runs successfully in CodeRunner, but I can't move the file where I want:
Any help would be appreciated
!/bin/bash
CHROME_BOOKMARK="$HOME/AppData/Local/Google/Chrome/User Data/Default/Bookmarks"
alias bmcsync='cp "$CHROME_BOOKMARK" "/d/someRepo/b-1 backup/5-1 bookmark/"'
I added the path to the end, but get an error
if I use "man bmcsync" I get command not found
- Labels:
-
Scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-30-2020 08:42 AM
Hi @bconcertiv,
While the "$HOME" variable may work natively on your computer, Jamf runs as root so the expected folder will often be different. To resolved this, most Jamf admins determine the actual user's file path by using
currentUser=$( /usr/bin/last -1 -t console | awk '{print $1}' )
You can test backing up the user's bookmark with this script:
#!/bin/bash
#Script to backup Chrome bookmark file to a specified location
#Shaquir Tannis 6-30-20
#Get current user
currentUser=$( /usr/bin/last -1 -t console | awk '{print $1}' )
#Chrome bookmark location
userChromeBookmark="/Users/"$currentUser"/Library/Application Support/Google/Chrome/Default/Bookmarks"
#Location to save bookmark
backupBookmark="/path/to/backuplocation/"
#Check if file exists and backup if it does
if [[ -f "$userChromeBookmark" ]]; then
#Backup Chrome bookmark file
cp "$userChromeBookmark" "$backupBookmark"
else
echo "No Bookmark file found"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-30-2020 11:09 AM
@shaquir Thank you this works perfectly. I really appreciate it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-31-2023 10:23 AM
The currentUser line above no longer works in Ventura. Swap in:
currentUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
Everything else works fine in Ventura.