Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to zip a folder and upload to my dropbox from Ubuntu shell. I intend to use this as a backup solution, so it would also be nice to run everyday and replace the older file.. If dropbox doesn't allow this what other cloud services you think it would work?

share|improve this question
up vote 3 down vote accepted

Zipping and moving files

The following will zip the directory foo in your home folder to a file called, which will also be stored in your home folder.

zip -r ~/ ~/foo

Now, all you have to do is move that file to your Dropbox:

mv ~/ ~/Dropbox/

If the backup file already exists, mv will overwrite it without prompting you, so be aware of that.

Automating it

You can put that in a script file, maybe call it and store it in your home folder.

zip -r ~/ ~/foo
mv ~/ ~/Dropbox/

That's it. If you rather want to keep your old versions, you can timestamp the created file by executing the date command before:

d=$(date +"%Y-%m-%d") # => this returns 2012-03-25, for example
zip -r ~/backup-$ ~/foo
mv ~/backup-$ ~/Dropbox/

Now, in your command line, make that file executable:

chmod +x ~/

The only thing you have to do to add this to a schedule is edit your crontab:

EDITOR=nano;crontab -e

Add the following line:

0   15  *   *   *   ~/ >/dev/null

Press Ctrl-O and enter to save. Your backup will now run at 15:00, every day. For more options, check out Wikipedia's article on Cron.

share|improve this answer
I would also suggest that if you want to keep a backup history (which is typically the good thing to do), you can have the script timestamp the .zip file and clean out older versions, if desired. – Ben Richards Jun 7 '12 at 21:25
True, I added an example. – slhck Jun 7 '12 at 21:30
@slhck perfect, thanks! – Francisco Tomé Costa Jun 7 '12 at 22:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .