My simple rsync backup scripts for Ubuntu 8.04 (also good for just about any Linux or BSD)

| | Comments (0) |

I'm no coding guru. And I feel like having to write my own scripts to get stuff done in Unix/Linux is all too much like reinventing the wheel.

Be that as it may, I hacked together these two short scripts to back up my /home files in Ubuntu 8.04 to an external USB drive. I put the scripts in /usr/local/bin and made them executable. I'm lazy enough that I used the Nautilus file manager to do this.

I run the scripts with sudo, meaning in my user account, I open a terminal and do this, entering my password when prompted:

$ sudo usb-backup

$ sudo usb-backup-exclude

For the second script, I created an "exclude file," which the script uses to exclude whichever directories or files I wish. In this case I use it to exclude the .gvfs directory, which breaks the script (and doesn't need to be copied anyway) and in this case to exclude my Thunderbird mail files, since they take so damn long to back up that doing it every day is something I'm not fond of. The beauty of the exclude file is that I can modify it while keeping the script the same.

I'm sure there are many of you who can do and have done a better job than this, but these two scripts appear to work, and that's what counts for me anyway.

There are some pounded-out notes for the scripts; feel free to remove them. They won't affect how the scripts work.

Here are the scripts:

usb-backup:

#! /bin/bash
# Use rsync to back up the /home folder to a 4 GB USB flash drive
# --delete allows for deletion of files on the backup that have been previously deleted on the source drive
# using --exclude to keep rsync from trying to back up ~/.gvfs
# Finally able to remove --ignore-errors now that .gvfs is excluded
rsync -av --delete --exclude 'home/steven/.gvfs' /home /media/disk/ubuntu
exit 0

usb-backup exclude:

#! /bin/bash
# Use rsync to back up the /home folder to a 4 GB USB flash drive
# --delete allows for deletion of files on the backup that have been previously deleted on the source drive
# setting up an exclude file to back up some directories and not others.
# Finally able to remove --ignore-errors now that .gvfs is excluded
rsync -av --delete --ignore-errors --exclude-from '/home/steven/Documents/shell_scripts/exclude' /home /media/disk/ubuntu
exit 0

And here is my "exclude" file which, as you can see from the script above, lives at /home/steven/Documents/shell_scripts/exclude:

/home/steven/.gvfs
/home/steven/.mozilla-thunderbird

.gvfs note: I've done similar scripts before in OpenBSD and Debian, and I don't believe either used the GNOME Virtual Filesystem, so there was no need to exclude ~/.gvfs when using rsync.

Leave a comment

Tech Talk column

Steven Rosenberg's weekly Tech Talk column, which appears Saturdays in the Los Angeles Daily News, is now available on the Daily News Technology page.

About this blog

New ways to sign in to comment: I just added the ability for prospective commenters on this blog to sign in using their AOL, Yahoo! and Wordpress.com accounts (for the past 200 posts anyway ... more than that will take an extensive, middle-of-the-night rebuild). That's in addition to the other sign-in choices, which include starting a Movable Type account on this blog, Typekey, OpenID, Live Journal and Vox. If you have trouble getting your Movable Type account verified, or any of the other sign-in options are not working properly, please e-mail me. With these added ways of signing in, there's more reason than ever for you to make a comment (or several!).




Steven Rosenberg aims to learn what he does not know. He writes about it here.



About this Entry

This page contains a single entry by Steven Rosenberg published on June 16, 2009 3:00 PM.

Ubuntu 8.04 update: Happy to be back in a Linux environment (revised) was the previous entry in this blog.

This is the 1,209th entry in Click is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Recent Comments

Powered by Movable Type 4.25

LXer

Links

Daily News technology
LXer
Distrowatch
Linus' Blog
David Pogue
BoingBoing
Linux Today
TuxRadar
Linux.com
Linux Planet
The Open Road
Linux Outlaws podcast
Dan Lynch
Fabian Scherschel
The VAR Guy
Larry the Free Software Guy
Chess Griffin
Linux Reality podcast
Desktop Linux
Practical Technology
Linux Devices
ZDNet
ZDNet U.K.
iTWire
CNet News
TechCrunch
The Register
Ars Technica
Reg Developer
Computerworld
Computerworld blogs
Steven J. Vaughan-Nichols at Computerworld
Debian
Planet Debian
Debian Forums
Debian News
debianHELP
debiantutorials.org
The Debian User
Wolfgang Lonien
Debian-News.net
Debian Administration
Debian Admin
Debian Weather
Ubuntu
Xubuntu
Kubuntu
Edubuntu
Gobuntu
Planet Ubuntu
Ubuntu Forums
Ubuntu Geek
Works With U
Dustin Kirkland
Ubuntu UK Podcast
Popey
gNewSense
CrunchBang Linux
OpenBSD
OpenBSD Journal
OpenBSD Ports
OpenBSD 101
Planet.OpenBSD.nu
jggimi's OpenBSD live CD
DaemonForums
BSDanywhere
Marc Balmer
Denny's OpenBSD blog
Polarwave's OpenBSD Tips and Tricks
Binary Updates for OpenBSD
Puppy Linux
Damn Small Linux
Tiny Core Linux
PCLinuxOS
Mandriva
Red Hat
Red Hat News
Red Hat Blogs
Red Hat: Truth Happens
Red Hat Magazine
CentOS
Planet CentOS
Fedora
Slackware
Slackbuilds
Robby's Slackware Packages
Slackblogs
dropline GNOME for Slackware
GNOME Slackbuild
GWARE - GNOME for Slackware
Wolvix
Zenwalk Linux
Vector Linux
Slax
Splack Linux — Slackware for Sparc
Nonux
How to Forge
marc.info BSD and Linux mailing list archive
FreeBSD
FreeBSD, the Unknown Giant
A Year in the Life of a BSD Guru
NetBSD
PC-BSD
DesktopBSD
DragonFlyBSD
DragonFlyBSD Digest
DesktopBSD
BSD Talk podcast
OpenSolaris
MilaX
BeleniX
DeLi Linux
Linux Loop
Electronista
Engadget
Gizmodo

Advertisement

Other blogs

Johnson Update in Inside USC with Scott Wolf
Has Bynum outgrown Kareem? in Inside the Lakers
Can the Angels just get to the end of this thing without an injury? in Farther Off the Wall
Neuheisel On: in Inside UCLA with Jon Gold
U.S. Roster for Final Two WCQ Announced in 100 Percent Soccer