This blog has moved

This blog is now at http://www.celesteh.com/blog

Monday 21 February 2005

doing CVS on a remote server as a backup strategy

there are some advantages to using CVS to manage your files. Not only does it provide a redundant copy, it keep track of previous revisions for you, which can be handy. also, if you find yourself generally using more than one machine, having your bookmarks in CVS could be handy so that you can have the same bookmarks across many computer and be able to change bookmarks on any computer and get the new bookmarks on every computer.

Obviously, you need to figure out what you want in cvs. Imagine that your computer's disk is on it's last legs. what files would you grab? those are the ones you want to backup and may be the ones you want in cvs

You need to install the developer kit on your mac, if you are using a mac. also, make sure that you have installed the optional bsd components of your operating system.

If your remote server is doing something weird, like running ssh on an unusual port, you will want to edit ~/.ssh config. Your file would look like:

Host host address
 Port port number
contact your sysadmin for more information on that.

You need to set an environment variable. If you run bash, edit ~/.bashrc and put in it:

export CVS_RSH=ssh

Ok, now ssh to your remote machine. you want to start a repository. you probably want to do this in your home directory, depending on what sot of permissions you have on the system. also, which filesystems are RAID? which are backed up? on my remote server, /home is RAID.

on the remote machine, type

cvs -d path to repository init

path to repository should be a full path name. for example, if your login name is brad, it might be: /Users/brad/Documents/cvs-repos . On my remote system, I used: /home/celesteh/cvsrepository

Ok, you've already got the list of files that you want to backup. Make a new directory containing all those files. Think about logical ways to break them up. I've decided to keep my library files in a separate distro than my documents.

tar cvf Documents.tar Documents/

gzip --best Documents.tar

scp Documents.tar.gz username@remote server:path to a temporary location

You've tar gzed the Documents that you want to save. You've copied that to your server. Now, log into the sever and re-expand:

cd path to a temporary location

tar xvzf Documents.tar.gz

Now cd into the directory where you have things to import and run the import command:

cd Documents

cvs -d path to repository import Documents vendortag releasetag

I don't know what those tags mean. i used "backup" and "documents":
cvs -d path to repository import Documents "backup" "documents"

You will have to enter a message describing your import. This is described further down.

The rest of this document deals with your local, personal computer and not the server. When you want to get this stuff back out, it doesn't matter if you already have a folder named Libraries or Documents. On my local machine (the mac), those folder are just inside ~/ . We've set this up to run from within the bash shell:

bash

cd ~

cvs -d :ext:username@server:path to repository -z 9 co Library

The -z 9 compresses your data before sending it across the network, because network transfer is usually a major bottle neck. If your network is fast, you can omit the -z9 where ever you see it, or change it to less compression. 9 is most compressed (slowest processing, but fastest network travel time). 1 is least compressed (fastest processing, but slow network travel time).

Then, when you update your bookmarks or something and you want to make sure it gets backed up

bash

cd ~/Library

cvs -z 9 commit [ -m "change message" ]

The square brackets indicate optional arguments. It will look for changed files and prepare a list of them. If you use the -m flag, you've already entered a comment about what's changed. otherwise, it will open a text editor where you can type in a comment. This text editor will usually be vi. Type a to start typing your comment. when you're done, press the escape key and then :wq . that is: colon followed by w followed by q. Then hit enter. It may put you in emacs (after typing your message, hit control-x then control-s then hit control-x followed by control-c) or pico (after typing your message, hit control-x then y and then enter)

When you switch to another machine which uses the same cvs files, type:

bash

cvs -z 9 update

to grab all the most recent versions.

You can find out what has changed by doing a diff

bash

cd directory managed by CVS

cvs diff

It will give you a list of changed files and also of files that are in your local copy but not in the archive. expect to see a lot of cache files. However, say, if you log your ichats, each new log is a new file. you will have to add them:
bash

cvs -z 9 add newfile

you will have to do a cvs commit to actually get your new files into the archive.

Tags: , ,

No comments:

Commission Music

Commission Music
Bespoke Noise!!