Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Possible Duplicate:
Version control for independent developers?

I have a folder containing all my code (working code, experiment code). I'd like to back it up to a zip file on an external hard drive or whatever is best. How do you guys backup your code?
Do you setup your own source control server?
Do you use a script to zip all files?

share|improve this question
    
What source control are you using? Let that be your guide. –  JeffO Sep 24 '11 at 21:17
    
for work, I use SVN, for hobby, I use git(github). The problem is that I don't want all my code pushed to github, which I only have a public account. –  AZ. Sep 24 '11 at 21:44
add comment

marked as duplicate by Walter, Anna Lear Sep 25 '11 at 0:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

8 Answers

One word: Git.

Commit locally as often as you like, giving you a backup. Push remotely as often as you like, giving you an offsite backup. Have a full history of all changes, be able to fork locally and remotely, so that you can play around with ideas.

And it's dead easy to set up. It's not sooo easy to learn, but anyone who can learn to code can learn to use Git by experience.

share|improve this answer
add comment

I use BitBucket which provides mercurial hosting. For free you can have unlimited private repositories (the only limits are on the number of people with access.)

For anything not in version control (mostly non-code stuff) I use dropbox.

share|improve this answer
add comment

Locally : I would have the code in two drives, along with a copy of code in USB Pendrive

Internet : I use google project hosting, or microsoft sky-drive. There are other sites too like Codeplex, git-hub but i haven't used them.

IMO Internet is more secure, because one can't really expect Google and Microsoft to go down :-)

share|improve this answer
1  
I don't understand your last line even with the smiley. Microsoft, Google, and Amazon have all had significant outages. –  Charles E. Grant Sep 24 '11 at 21:59
1  
outage is an altogether different scenario and every site on a network can have that. What I was emphasizing was on loss of data, which has seldom happened(if happened) to anyone. –  Pankaj Upadhyay Sep 25 '11 at 4:43
add comment

I write code on my Mac / Linux box and have a separate Linux shell account online with my Web host. So I wrote a shell script that tars and gzips my code's directory and then scp's it to my online shell account. The script kind of looks like:

#!/bin/csh -f

if ($#argv == 0) then
    echo "Usage: archive_and_upload.csh dir"
    exit 1
endif

set filename = $argv[1]

if (! -e $filename) then
    echo "$filename does not exist"
    exit 1

else if ((-e $filename) && (! -d $filename)) then
    echo "$filename exists but is not a directory"
    exit 1

endif

set timestamp = `date "+%Y_%m_%d__%H_%M"`

set output_link = "${filename}_${timestamp}"

if (-e $output_link) then
    echo "The link $output_link could not be created because it already exists."
    exit 1
else
    ln -sf $filename $output_link
endif

set output_tar_filename = "${output_link}.tar"
set output_targz_filename = "${output_tar_filename}.gz"


# Create tar file 

echo ""
echo "Creating tar file '$output_tar_filename'"

tar hcvpf $output_tar_filename $output_link
set tar_status = $status
if ($tar_status != 0) then
    echo "tar failed with status $tar_status"
    # Clean up
    if (-e $output_link) then
        rm $output_link
    endif
    exit 1
endif
echo "Done."


# Create gzip file 

echo ""
echo "Gzipping tar file '$output_tar_filename'"

gzip $output_tar_filename
set gzip_status = $status
if ($gzip_status != 0) then
    echo "tar failed with status $gzip_status"
    # Clean up
    if (-e $output_link) then
        rm $output_link
    endif
    exit 1
endif
echo "Done."


# Upload to the server

echo ""
echo "Uploading  '$output_targz_filename'  to server"
echo ""

scp -p $output_targz_filename  MYACCOUNT@ACCOUNTHOST.COM:target/directory/ 

# Clean up
if (-e $output_link) then
    rm $output_link
endif

exit 0
share|improve this answer
add comment

Online backup service. There are many now. But a local cvs respostory is a good idea for backup of code, because the development history it provides is eventually invaluable.

share|improve this answer
add comment

Local personal projects: Git to a repo stored in my Dropbox account.

Local work projects: SVN to a remote server, and a rotating copy stored in my Dropbox just in case.

share|improve this answer
add comment

I use one of these two techniques:

A. Use source control, github, google code, codeplex
B. If source control is overkill for your project, use dropbox or live mesh to basically duplicate code across multiple machines.

share|improve this answer
add comment

I do most of my work at home under Mac OS X. I have my own Subversion repository. I run TimeMachine, which does continuous backups of the entire system to an external drive. At the end of every month I swap external drives and take the offline drive to work for safekeeping. I'm sure there are TimeMachine equivalents for Linux and Windows.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.