3

votes

Vote

os-utilities in OS & Utilities Channel,
Written by: Tim Voet on Jul 30 2010, 2:20pm

Using Ubuntu Command Line and Dropbox to AutoSync Notes

Tim here with an exciting tip to automate backup and synchronize notes on your Linux operating system.  I am a what most people would call a power user when it comes to the command line, so this trick will be using the Linux command line and some of the functions applicable to it.  


Utilizing DropBox

Aside from signing up and downloading Dropbox, step one is to set up the folder that will contain the notes you want to synchronize.  Remember that Dropbox can be accessed via a browser as well as the desktop application, so getting info from one computer to another shouldn’t be hard once you have a folder designated on your Dropbox account.  In this example, we will sync a bunch of files we use for note taking from Ubuntu to Dropbox and vise versa.  


Creating the Shared File

The naming convention I used was “notes.”  So, I have a folder inside of Dropbox called notes.  Then I created a local link (known as a symbolic link) on my computer (in my home folder called notes that links to the notes folder in dropbox) so that you aren't explicitly pointing to Dropbox. (This also works if you don't want it linked or if you want to link it to something else such as ubuntu one)


Setting your Editor

Next, set up your editor of choice (the variable on most linux distributions is $EDITOR).   On most linux systems this defaults to vim, but you can use anything you want.  In the past I have tried: vim, nano, gedit, and gvim. (can you tell that i’m a Gnome guy ;) )

Bash Functions

The next step involves the two bash functions mentioned in this Lifehacker article.


n() {
    $EDITOR ~/notes/"$*".txt
}

nls() {
    ls -c ~/notes/ | grep "$*"
}

To create/edit a note file, simply type:
n some note name ( for example n shopping list )
In this command line, n is the command to create/edit a note
"Some note name" is any name you want. Spaces are also welcome.
image
This creates a file in the notes folder with "some note name".txt.
if the file already exists, it will open it for editing

image
To list the notes you have created issue the nls command.  If you want to filter that list by some pattern just pass the text you want to filter

i.e.  nls shopping would return a list of files that contained shopping in the title
image

The beauty of this trick is that when you save, it gets synchronized to all machines that are linked to your Dropbox, including if this folder is shared with anyone else.

Backing things up can be a time consuming process and to be effective, it requires lots of consistency.  This simple trick will keep your notes backed up and available from anywhere automatically.

 

Citizens Comments

petter hamrin says:

Hello, I just installed dropbox on my Ubuntu server(command line, no graphical interface), it is syncronizing fine, everything works out like it is supposed to do..

BUT i want to choose what folders to sync.... Do you know a way to set that up ??

 

cheerz

Petter

petter.hamrin@gmail.com

0

Votes

Vote
Aug 13 2011, 7:28pm | Report

Post your comment

default Avatar

You might be interested in these related contributions

SoftCity Promotion

About the Author

Tim Voet

Montreal, Quebec, CA

64 contributions

software social commerce