A Shell script to backup all your pinboard bookmarks.
#!/bin/bash
# username=my_pinboard_username
# password=my_pinboard_password
cookies=cookies.txt
backup_dir="~/Downloads/pinboard_bkup"
# optionally you can hard-code credentials (username, password) above and
# comment out the following two prompt lines.
read -p "Please enter your pinboard.in username: " username
read -p "Please enter your pinboard.in password: " password
echo "---> Backing up Pinboard bookmarks... "
if [ -d $backup_dir ]; then
echo "---> Backup to folder ${backup_dir} OK."
else
echo "---> Creating backup folder ${backup_dir}."
mkdir -p "$backup_dir"
fi
curl -s -d "username=$username&password=$password" \
'https://pinboard.in/auth/' -c $cookies > /dev/null 2>&1
curl -s -L -b $cookies -c $cookies \
'https://pinboard.in/export/format:html/' | bzip2 -c > \
"$backup_dir"/pinboard-bookmarks-`date "+%Y%m%d%H%M"`.htm.bz2
if [[ -f $cookies ]]; then
rm $cookies;
fi
# Remove Pinboard bookmark backup files older than 14 days
find "$backup_dir" -name 'pinboard-bookmarks-*.htm.bz2' -type f -mtime \
+14 -maxdepth 1 -print0 | xargs -0I{} rm {}
echo "Done."