Archive

Posts Tagged ‘dropbox’

ménage de printemps (spring cleaning)

March 22, 2014 Leave a comment

Problem
My Dropbox folder was at 98.5%, so it was time to do some cleanup. Which directories are the largest? Which files are the largest?

Solution

alias top10dirs='du -hsx * | sort -rh | head -10'
alias top10files='find . -type f -print0 | du -h --files0-from=- | sort -hr | head -n 10'

The first one shows the top 10 largest directories, while the second one prints the top 10 largest files. Directory and file sizes are shown in a human-readable format.

Samples

$ top10dirs 
60M     20090629-deploy
60M     20090327-deploy
56M     kgm
55M     exist-deploy-v3-20100710
55M     exist-deploy-v3-20100521
...
==============================
$ top10files 
60M     ./20090629-deploy/20090629-deploy.zip
60M     ./20090327-deploy/20090327-deploy.zip
55M     ./exist-deploy-v3-20100710/exist-deploy-v3-20100710.zip
55M     ./exist-deploy-v3-20100521/exist-deploy-v3-20100521.zip
49M     ./exist-deploy-v3-20100409/exist-deploy-v3-20100409.zip
...

Credits

  • top10dirs is from here
  • for top10files I wrote a Python script, but reddit user farsass pointed out that it can be solved easier in the shell

Linux host, Windows guest, shared Dropbox folder

February 16, 2014 Leave a comment

Problem
My primary operating system is Linux but since I need to work with Powerpoint too, I installed Windows 7 in VirtualBox. Under Windows I prepare my presentations but I want them synchronized on all my machines. For the synchronization I was using Dropbox.

I had Dropbox on Linux (host machine) and on Windows (guest machine) too. When I edited a file under Windows, Dropbox synced it to the Linux host too (the Windows client uploads it to the cloud; the Linux client downloads it from the cloud). It worked fine, though it was not not optimal. If I didn’t use the Windows guest for a long time, then after a boot I had to wait some time till Dropbox synced everything and I could start working only after that.

However, something happened to the Windows Dropbox client recently. Maybe it’s a bug, I don’t know, but the Dropbox client in my Windows guest became terribly slow. It keeps syncing but it doesn’t upload the changes, or I need to wait an hour or so to upload a file 1 MB of size. This is ridiculous and unacceptable. Note that I dind’t experience similar issues with the Linux client.

How to have a synchronized folder between a Linux host and a Windows guest without a Dropbox client on the guest?

Solution
First I made sure that my Dropbox folders were synced between the host and the guest. After this I uninstalled Dropbox on Windows and removed the C:\Dropbox folder entirely. Since it was synced with the Linux host, I had an exact copy of the Dropbox folder on Linux. Then shut down the Windows guest.

Here (http://www.maketecheasier.com/share-files-in-virtualbox-between-vista-guest-ubuntu-host) you can find an excellent post on how to set up a shared folder between a Linux host and a Windows guest. On the Linux host I shared my Dropbox folder ($HOME/Dropbox) that appears now as a new drive in the Windows guest (G:\ in my case). Now, if I modify something under Windows, it will be visible immediately in the Linux file system that the Dropbox client on Linux will notice and sync.

With this I could solve two problems. First, when I boot up the Windows guest, I don’t need to wait for the Dropbox client to sync. Second, if I change something under Windows, it is still synced to the Dropbox cloud, though I have no Dropbox client on Windows anymore.

SpiderOak: a great Ubuntu One alternative

July 31, 2013 Leave a comment

Problem
Dropbox is awesome but it has a drawback. It treats symbolic links in a terrible way. So, if you want to sync a directory between several Linux machines AND you want to use symbolic links in this common directory, then forget Dropbox. I also use Windows machines with Dropbox, and my symbolic links were always f* up.

To avoid this problem, I decided to use Ubuntu One next to Dropbox. In the “Ubuntu One” directory I put content that I wanted to share between my Linux machines. Ubuntu One simply ignores symbolic links, thus I used a script on each machine to recreate the links. It worked well until Ubuntu One refused to start on my home machine… It is written in Python (that I love by the way), but the libraries somehow got messed up and Ubuntu One quit with an error. F* awesome!

Solution
So, what should I use instead of Ubuntu One? The alternative must treat symbolic links normally (or, to be safe, just ignore them), otherwise it’s useless for me.

And that’s how I found SpiderOak. Basically it works just like Dropbox, but similarly to Ubuntu One it nicely ignores symbolic links.

KeePassX + TrueCrypt + Dropbox: a secure and portable password management solution

April 14, 2013 4 comments

Read the update at the bottom.

Problem
I’ve arrived at the point that I’m fed up with the f* passwords. I can’t memorize them all so I usually write them in an exercise book that I keep at home. But what if I need something from it at my workplace? On the other hand, this booklet is already full (with other pieces of info too), so when I need a password from it, I need to search it for minutes… Damn. It would be so nice if I had all this information in a file on my machine but in a secure way.

Solution
The ideal solution is a password manager. But which one to choose? There are a lot. Since I also use Windows from time to time, I needed a cross-platform solution. First I thought of using a command line manager but finally I decided to use a graphical one; after all it looks nicer and easier to use (and I didn’t want to learn new command line options that I forget if I don’t use it for a few weeks…). This is how I got to KeePassX, which perfectly fulfills my needs. It’s also in the Ubuntu repos.

As I use several machines, the password database should be available everywhere. So let’s store it on Dropbox. But how safe is it? Well, it’s rather safe; your KeePassX database has a master password, which uses an AES-256 encryption but still… the devil never sleeps. Could we add an extra layer of security?

Yes, we could. With TrueCrypt you can create an encrypted file that can be mounted as a new volume (as if you had attached a USB stick for instance). I put the KeePassX database on this volume. Thus, in order to use the database, first I must mount the container file as a TrueCrypt volume, and then I can open the database file, but it also asks for the master password. Now I dare put the TrueCrypt container file on Dropbox :)

So, here is my setup (summary):

  • Create a KeePassX database and provide a master password. You can change this password later under the File menu. It uses AES-256 encryption.
  • Create a container file with TrueCrypt. The KeePassX database is very small so I set the container’s size to 1 MB. Encryption algorithm: AES-Twofish-Serpent cascading encryption with the XTS method. Hash algorithm: Whirlpool (tip from here). Of course, use a different password for this container file than for the KeePassX database. The TrueCrypt password should be long (20 to 30+ characters).
  • Mount the container file and move the KeePassX database on the mounted volume.

OK. So far so good. But how to use the database painlessly? I made a simple script that mounts the container file and then opens the database. Just customize the constants in the header part. Launch it and simply type in the passwords. Instead of one password (for the database), you will have to provide two extra ones (for the TrueCrypt volume and your root password for being able to mount a new volume). I think this sacrifice is worth considering the additional security you gain. It may be a bit paranoid but on the Internet be paranoid. You know: Trust is a weakness :)

#!/usr/bin/env python

"""
Start KeePassX.
Mount the truecrypt container if necessary.

by Jabba Laci 2013 (jabba.laci@gmail.com)

http://ubuntuincident.wordpress.com/2013/04/14/keepassx-truecrypt-dropbox/

"""

import os

TRUECRYPT = '/usr/bin/truecrypt'
KEEPASSX = '/usr/bin/keepassx'
#
CONTAINER_FILE = "{home}/Dropbox/keepassx/container.dat".format(
    home=os.path.expanduser('~')
)
MOUNT_POINT = '/media/truecrypt9'
KDB = '/media/truecrypt9/JabbaDB.kdb'

def mount_truecrypt_file():
    """
    Open the truecrypt container file that
    includes the keepassx database.
    """
    if not os.path.isfile(KDB):
        cmd = 'sudo {tc} {container} {mount}'.format(
            tc=TRUECRYPT, container=CONTAINER_FILE, mount=MOUNT_POINT
        )
        print '#', cmd
        os.system(cmd)
    else:
        print '# container already mounted to', MOUNT_POINT

def open_kdb():
    """
    Open the keepassx database file on the previously mounted volume.
    """
    if not os.path.isfile(KDB):
        print "Error: the container file was not mounted."
    else:
        cmd = "{kpx} {f} &".format(kpx=KEEPASSX, f=KDB)
        print '#', cmd
        os.system(cmd)

def main():
    mount_truecrypt_file()
    open_kdb()

###################################################################

if __name__ == "__main__":
    main()

[ comments @reddit ]

Update (20130501)
After two weeks of usage, I think adding truecrypt is an overkill. The problem is the following: I want to use this keepassx database on several machines, that’s why I put it on dropbox. That’s fine. But each time I need to mount the truecrypt volume that I often forget to dismount. At my workplace my machine is always on, so sometimes (often) I leave the volume mounted when I go home. If I want to add a new password to the database at home, dropbox creates a conflicted copy of the truecrypt file when I save the keepassx database. So I end up with two different databases that I will have to merge manually. It’s already happened to me 2 or 3 times…

So I removed truecrypt from the chain. Now I have a keepassx database (with a long password) stored on dropbox. I only have to pay attention to close keepassx when I leave my workplace but it’s feasible: when I copy a password from it, I close it immediately.

Symbolic links are not treated properly on Dropbox

March 12, 2013 Leave a comment

If you try to use symbolic links in your Dropbox folder, you’ll end up with a mess :( Here is a nice summary of the problems. It turns out that it’s because of a stupid decision that was made by Dropbox a long time ago.

If you want them to implement symlinks properly, please vote here.

Remote control a script from home via dropbox

November 9, 2012 4 comments

Problem
At my workplace I want to leave a script running on my desktop 24h/day. However, from home I cannot login to my machine, so if I want to stop/pause the script, I must go in to the office.

Still, how could I give commands for such a script from home?

Solution
I came up with the following idea. The script is put in my Dropbox folder and it is launched from there. At home I can create some special command files that are automatically synchronized on my office machine too. And when the script notices such a command file, it can react. My command files are called “stop” and “wait” and they can be empty.

The script checks periodically the presence of these files:

def check_commands():
    """
    Remote commands via dropbox.
    """   
    if os.path.isfile('stop'):
        os.unlink('stop')
        print '\nstop received, terminated.'
        sys.exit()
    #
    while os.path.isfile('wait'):
        sys.stdout.write('w')
        time.sleep(5)

The command “stop” terminates the script. The command “wait” pauses the program.

Categories: python Tags: ,

Dropbox: don’t sync certain directories; empty the cache

April 28, 2012 Leave a comment

Problem
I have a laptop with a small HDD. I want to use Dropbox on it too but in this case I hardly have any free space left. Could I select certain directories that I don’t want to see on my laptop?

Solution
Yes, it’s possible. Here is a detailed description how to do that. In short: go to Dropbox -> Preferences…, select the Advanced tab and click on Selective Sync… Here untick the directories that you don’t need on your current machine. When you click on Update, these directories will be removed from your local Dropbox folder but they remain on the server, so there is no need to worry. They are simply not synced with the current machine.

However, you may notice that after Dropbox has removed these directories, you still don’t have more free space :( Well, the dropbox client put the deleted files in the cache… Here is how to empty the cache. In short: stop the client, delete the content of the cache folder (but leave the cache folder itself), restart the client.

Follow

Get every new post delivered to your Inbox.

Join 72 other followers