There are more sophisticated ways to do it, but here is just a simple shell script that creates a simple time-stamped backup of the places.sqlite file.
This can be useful if Firefox randomly decides to get rid of some browsing history, or if Google Chrome randomly decides to slice off all browsing history beyond a threshold. (archive.today)
Make sure the working directory is where places.sqlite is located.
This script is for Firefox. You may rename places.sqlite
or change the backup interval to adapt it to your needs.
dtstamp() { date +%Y%m%d%H%M%S ; } # Generates YYYYMMDDHHMMSS time stamp. "%N" is unsupported by some terminals.
mkdir -p hist.bk # Make history backup folder, if it does not already exist.
if [ ! -e places.sqlite ]
then echo Firefox history file not found. Exiting.
exit # Exit if history file not found.
fi
while : ; do
cp -n places.sqlite "hist.bk/places.bk$(dtstamp).sqlite" # Create copy.
sleep 86400 # Wait 86400 seconds (24 hours). Some terminals don't support m/h/d units.
done # Restart loop. Break loop using Ctrl+C.
I will make one for Google Chrome too later.
With root access, it can also be used in Android Terminal to back up the mobile phone browser's browsing history.
It could also be extended by things like a file counter (00001, 00002, 00003, etc.) and many options, features, debug/status report functionality and interactive functionality, coloured indicators, automatically finding right working directory, etc. but that is out of scope for this example.
If you have any suggestions for improvement, please write it in the comments.
There are more sophisticated ways to do it, but here is just a simple shell script that creates a simple time-stamped backup of the *places.sqlite* file.
This can be useful if Firefox randomly decides to get rid of some browsing history, or if [Google Chrome randomly decides to slice off all browsing history beyond a threshold.](http://archive.today/2016.10.08-115448/http://www.obsidianforensics.com/blog/archived-history-files-removed-from-chrome-v37)
Make sure the working directory is where *places.sqlite* is located.
This script is for Firefox. You may rename *`places.sqlite`* or change the backup interval to adapt it to your needs.
```
dtstamp() { date +%Y%m%d%H%M%S ; } # Generates YYYYMMDDHHMMSS time stamp. "%N" is unsupported by some terminals.
mkdir -p hist.bk # Make history backup folder, if it does not already exist.
if [ ! -e places.sqlite ]
then echo Firefox history file not found. Exiting.
exit # Exit if history file not found.
fi
while : ; do
cp -n places.sqlite "hist.bk/places.bk$(dtstamp).sqlite" # Create copy.
sleep 86400 # Wait 86400 seconds (24 hours). Some terminals don't support m/h/d units.
done # Restart loop. Break loop using Ctrl+C.
```
-----
I will make one for Google Chrome too later.
With root access, it can also be used in Android Terminal to back up the mobile phone browser's browsing history.
It could also be extended by things like a file counter (00001, 00002, 00003, etc.) and many options, features, debug/status report functionality and interactive functionality, coloured indicators, automatically finding right working directory, etc. but that is out of scope for this example.
If you have any suggestions for improvement, please write it in the comments.
(post is archived)