Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # filename: backupmozilla (do not rename it backupfirefox or anything with firefox in the name... see the pgreg below)
- if [ -z "$1" ]; then
- frequency="hourly"
- else
- frequency=$1
- fi
- mozillalocation="$HOME/.mozilla"
- backuplocation="$HOME/backup/mozilla/$frequency"
- thisscript=`basename $0`
- if [ ! -d "$backuplocation" ]; then
- mkdir -p $backuplocation
- fi
- if [ $(ps aux | grep "[${thisscript:0:1}]${thisscript:1} $frequency" | wc -l) -gt 3 ]; then
- echo "$thisscript $frequency is already running, exiting."
- exit
- fi
- name=$(date '+%Y-%m-%d_at_%H.%M.%S'.mozilla.tar)
- if pgrep firefox >/dev/null 2>&1; then name=$name.running; fi
- cd $mozillalocation
- tar -cf $backuplocation/$name *
- cd $backuplocation
- numbackups=$(ls | wc -l)
- if [ $numbackups -gt 5 ]; then
- ls -t | awk 'NR>5' | xargs rm
- fi
Advertisement
Add Comment
Please, Sign In to add comment