b5media.com

Advertise with us

Enjoying this blog? Check out the rest of the Technology Channel Subscribe to this Feed

New Linux User

HOWTO: Do a Quick and Dirty Backup

by Jon on June 19th, 2006

I ran across this script on Linux Questions. It will copy (cp) all files in a user’s home directory that have changed in the last X number of days into /tmp/backup for further processing (likely burning to a CD or DVD). Now there are many, many ways to backup files in GNU/Linux, but this is a quick little script that will work nicely.

There are two potential changes you’ll have to make to this script to customize it for your system:

1. Change ‘user’ to the username you’d like to backup
2. Potenially change the ‘-1′ to something else. Currently, the ‘-1′ refers to the number of days old a file has to be. If you want 2 days, substitute ‘-2′ and so on.

#!/bin/sh

NEWDIR="/tmp/backup"

for i in `find /home/user -type f -mtime -1`; do
DIR=`dirname $i`
DEST=$NEWDIR/$DIR
mkdir -p $DEST
cp -a $i $DEST
done

Thanks Crabboy!

POSTED IN: How To

0 opinions for HOWTO: Do a Quick and Dirty Backup

  • No one has left a comment yet. You know what this means, right? You could be first!

Have an opinion? Leave a comment:




Check Spelling
Activate Spell Check while Typing