Posted in Quick Tips

Backing Up Only Recent Files

Backing Up Only Recent Files Posted on February 11, 2024Leave a comment
Jed Reynolds has been known to void warranties and super glue his fingers together. When he is not doing photography or fixing his bike, he can be found being a grey beard programmer analyst for Candela Technologies. Start stalking him at https://about.me/jed_reynolds.
(Last Updated On: March 12, 2024)

 

Gnarly Backup School Series

Getting backups done is important. Sometimes what you have to backup and what you want to backup make quite the contrast. Consider I never want to back up my .mozilla/firefox//cache directory. Let’s cover how to avoid that. Because if you don’t, things get really bunk, little dude.

Before you freak out man, prepare for some regular expressions. More regular than, huh and eh. “Everthing” separated by the gnarly pipe | is a pattern that will be matched by egrep.

IGNORE="$LOGNAME/(\\.mozilla/firefox/aq0d3bz0xy/cache|\\.gvfs|\\.cache|\\.Trash)'
cd $HOME/..
find $HOME -type f \
| egrep -v $IGNORE \
> /tmp/backup_list
tar cf /mnt/backups/backup.tgz --use-compress-program lbzip2 -T /tmp/backup_list

That will backup your whole home directory except anything you slap into IGNORE. If that includes a whole git tree or two, well, you might be waiting for a long time.
Therefore, let’s concentrate on things that just changed since the last backup.

cd $HOME/..
if [ ! -f $HOME/.recent ]; then
find $HOME -type f \
| egrep -v $IGNORE \
> /tmp/backup_list
else
find $HOME -type f \
-newer $HOME/.recent \
| egrep -v $IGNORE \
> /tmp/backup_list
fi
touch $HOME/.recent
tar cf /mnt/backups/backup.tgz --use-compress-program lbzip2 -T /tmp/backup_list

Now we have a way to backup only recent things. Using all our cores, courtesy of lbzip2.

More great Linux goodness!

Jed Reynolds
Jed Reynolds
Jed Reynolds has been known to void warranties and super glue his fingers together. When he is not doing photography or fixing his bike, he can be found being a grey beard programmer analyst for Candela Technologies. Start stalking him at https://about.me/jed_reynolds.

Leave a Reply

Please Login to comment
  Subscribe  
Notify of