Wednesday, June 17, 2009

Large Hidden Files

I'm working on another backup script. I admit it had been over a year since I had backed up my home hard drive. In that time, the stuff my old script had been backing up from my home directory got a lot bigger. Why? I found a couple obvious culprits that I should have seen right away, but then it was less obvious. Running du | sort -rn is always insightful when this problem comes up, and I found that I had a .local directory that was 2.3 GB in size and a .cache that was almost 1 GB. Ouch. Looks related to tracker. The other biggie that I had totally missed was that I had played around with VirtualBox, and it stores its hard drive images in the hidden .VirtualBox directory. What is with these programs stashing huge amounts of data in hidden directories? In the case of VirtalBox, it could be very important data. Is that smart to hide it from the users like that? I don't like it.

Thursday, June 11, 2009

Playing With Dar

I'm playing with backups again. Most recently, I'm looking at dar. Some quick notes:

To backup just /etc, become root, make sure your pwd is /, and type this:

dar -v -c /path/to/etc-backup -g etc
This will create a file named etc-backup1.dar at the path you specified. The -v is optional. To do the same but encrypt the archive do this:
dar -K passphrase -v -c /path/to/etc-backup -g etc
Where "passphrase" is your sneaky passphrase. To list the contents of the archive:
dar -K passphrase -l /path/to/etc-backup
Of course, you leave out the -K passphrase if you didn't encrypt it in the first place. Notice that you don't give it the full filename, ever. Getting more advance, to write the backup to a file on a remote machine over ssh, do this:
dar -c - -g etc | ssh user@host dd of=/path/to/etc-backup.1.dar
You tell dar that the backup file is stdout, pipe that to ssh, and use dd on the remote side to put the backup into the file. Note that you need to give the resulting file a proper dar filename since you don't have dar on the remote side doing it for you. Not a bad little tool.