Results tagged “Carla Schroder” from CLICK

Updated: The Debian Mac gets a backup plan

| | Comments (3) |

Since the Power Macintosh G4/466 has enough space for four hard drives, I decided to put a second one in the box.

I originally planned to dual-boot Debian Etch and OpenBSD, but I still can't get the system to even boot OpenBSD after an install, so I abandoned that plan. After two successful OpenBSD installs on i386, I figured I could handle a MacPPC install, but it was not to be.

And since Debian Etch installs — and runs — so well, I'm keeping it.

Before the last unsuccessful OpenBSD install, I set the second drive's jumpers to make it a "slave." Then I used an extra IDE cable as an "extension cable" so I could plug the second IDE input from the too-short motherboard cable into the second drive.

I'm pretty accustomed to chaining IDE cables together for longer runs — I did it for over a year with my VIA thin client.

Anyway, I booted into Debian Etch, ran the GNOME Partition Editor to create an ext3 filesystem on the backup drive, then mounted it and did a few tests with rsync.

Yep, I'm using rsync to do the backups. I first learned about it in Carla Schroder's great "Linux Cookbook" (which all of you should own ... and which O'Reilly should beg Carla and pay her well to revise immediately).

Rsync is in the default Ubuntu install, but in Debian Etch, you have to add it:

# aptitude install rsync

In order to use the backup drive, I created a directory called hdb1 in /media and used it to mount the drive:

# mkdir /media/hdb1

Instead of mounting it from the command line, I put a line in /etc/fstab.

Here's what /etc/fstab looks like on this machine:

# /etc/fstab: static file system information.
#
#
proc /proc proc defaults 0 0
/dev/hda3 / ext3 defaults,errors=remount-ro 0 1
/dev/hda5 /home ext3 defaults 0 2
/dev/hda4 none swap sw 0 0
/dev/hdb1 /media/hdb1 ext3 defaults 1 2
/dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0

I made a directory called homebackup on /media/hdb1, which is where my backups of /home will go:

# mkdir /media/hdb1/homebackup

To run the backup from the command line, here's what I did (at a root prompt):

# rsync -av --delete /home /media/hdb1/homebackup

(A note on rsync: The FIRST time I ran rsync with the line above, a home directory was created in /media/hdb1/homebackup. Subsequent uses of the same rsync command just update the directory; they don't create it again.)

The beauty of rsync: I really didn't explain rsync all that well. Basically, it's a great backup utility that, when used multiple times, only backs up the changes between the source and the destination directories.

What the switches mean in rsync -av --delete:

-a stands for archive mode. It is a catch-all switch that turns on a variety of things in rsync, most of which I don't understand. I use all of these switches because Carla Schroder told me to. For more (or less) clarity, check out the man page for rsync.

-v stands for verbose so rsync outputs to the console exactly what it's doing.

--delete tells rsync to delete files in the destination directory that have been previously deleted from the source directory. Without this switch, the backup directory would just get bigger and bigger. You might want that; without --delete, everything you delete would still be in the backup directory. But I don't, so I'm using this switch.

in order not to have to remember to type my entire rsync command with the switches and the directory information, I put it in a very simple shell script in /usr/local/bin.


I called the shell script backup — can't forget that.

Here's what is in the /usr/local/bin/backup file:

#!/bin/bash

# This file backs up the /home partition to the secondary drive with rsync
rsync -av --delete /home /media/hdb1/homebackup

To make the file executable, I ran:

# chmod a+x /usr/local/bin/backup

I'm not a big fan of using su to root, so I added my user account to the sudoers file (after I su'd to root):

# visudo

When you invoke visudo from a root prompt, the system opens the sudoers file with the default editor. Usually that editor is vi, but in Debian, the default editor, as configured, is nano. I've been using vi a lot lately in OpenBSD (with the i386 systems on which I can actually successfully install it). But for me it's easier to use nano, with it's F3 to save, CTRL-x to exit, and just moving the cursor around with arrow keys and not having to worry about going from command mode to insert mode as in vi.

Now that my little vi rant is over, here's what I did in the sudoers file after visudo brought it up in nano:

I gave my user account the same privileges as root. I wouldn't do this for other users; I'd figure out how to more finely grain the permissions, which is what sudo is really good at. But I'm not running a huge multiuser box, so giving my user account those privileges is good enough for now.

Here's what the relevant section of the sudoers file looks like:

# User privilege specification
root ALL=(ALL) ALL
steven ALL=(ALL) ALL

Back to the backups: This script will run without sudo or su privileges, but the --delete switch will not work because the non-root user doesn't have privileges in the lost+found directory in /home. So if you want to back up the entire /home directory, including all the files for all users, you should run it this way:

$ sudo backup

or after su to root:

# backup

Of course, if you want to set this up for your individual users, you can rewrite the rsync line to only back up their own /home files:

rsync -av --delete /home/steven /media/hdb1/homebackup

Then they could run it from a regular prompt, without root privileges, and it will work.

Since I'm the only user of this box, I made the rsync command cover the entire /home folder, which means, for me, using sudo to make it work.

What about a cron job? Sure, you could do this as a cron job, but I'm not in the habit of leaving the box on all the time, so cron (or even anacron) doesn't fit in with my computing habits. I guess anacron, which runs jobs after a certain interval of time has passed (and not only at certain, specified times), would work, but I'd rather just run the shell script periodically and see the jobs scroll down my terminal window.

But like anything in Unix, there's more than one way to skin any given cat.

Ubuntu note: In Debian, the "main" user does not automatically have sudo privileges. But in Ubuntu, that user does have sudo ability. You don't have to use visudo at all for that user; just use sudo from the get-go. I'm not sure about subesequent users in Ubuntu, but I sure hope they don't have sudo privileges by default; I think they don't but I don't have a Ubuntu box handy to check.

The trade-off for Ubuntu users is that they can't su to root. Well, they can ... Ubuntu encourages you to use sudo, but you can get a root shell this way:

$ sudo su

After you type in your password, you will have a root prompt:

#

As I said, I'm not a fan of using su to root, and I'd rather use sudo, but there are some things that sudo can't do, and that's when the Ubuntu su trick is necessary. I'd like to thank whoever it is who passed that one along to me.

Conclusion: If you hae a place to back up your files, using rsync is a great way to make those backups. Rsync also excels at backups over SSH, which Carla Schroder goes into in great detail in her book. She also shows you how to set up an rsync server.

Just buy the book already, will ya?

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.



Recent Comments

Steven Rosenberg on Updated: The Debian Mac gets a backup plan: Thanks for the clarification on $ sudo -i I rarely need a root shell ...

vorbote.myopenid.com on Updated: The Debian Mac gets a backup plan: "sudo su" is unsighltly. Particularly when "sudo -i" is the proper way ...

auser on Updated: The Debian Mac gets a backup plan: rdiff-backup is better for backups than just rsync. rsync is good for ...

Powered by Movable Type 4.25

Tags

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
Webware
Beyond Binary
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
Aaron Toponce
Ubuntu
Xubuntu
Kubuntu
Edubuntu
Planet Ubuntu
Ubuntu Forums
Ubuntu Geek
Works With U
OMG! Ubuntu!
I' Been to Ubuntu
Tanner Helland
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
Lucky 13's Linux blog (lots of Tiny Core)
Lucky 13's BSD blog
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
hubertf's NetBSD Blog
PC-BSD
DesktopBSD
DragonFlyBSD
DragonFlyBSD Digest
DesktopBSD
BSD Talk podcast
BSD Magazine
OpenSolaris
MilaX
BeleniX
DeLi Linux
Linux Loop
Electronista
Engadget
Gizmodo
xkcd – A webcomic of romance, sarcasm, math and language
Nixie Pixel
Technology for Mortals

Advertisement

Other blogs

The Early Words: UCLA hoops notebook in Inside UCLA with Jon Gold
Tuesday Kicks: Chivas USA Win & More in 100 Percent Soccer
Answer Tuesday! (Part 7) in Inside USC with Scott Wolf
Medical news in Inside the Lakers
Globies on Ice: Not so nice in Farther Off the Wall