venerdì, ottobre 11, 2013

Secure backup on cloud with raspberry

Yesterday my usb drive connected to the raspberry is dead and I lost about 20 gigabytes of data. This morning I implemented a system of automatic backup cloud to prevent these problems.

I used box.com will have access to 50gb and the webdav protocol

Requirements:

  1. sudo apt-get update && sudo apt-get install davfs2

Now we create a mount point to access the cloud

  1. mkdir /media/box

Check if the connection to box. works

  1. sudo mount -o uid=pi -o gid=pi -t davfs https://dav.box.com/dav /media/box

The system will ask user name and password box.com, if they are correct we could browse through our account in the folder /media /box

  1. ls /media/box

If the test is ok, close all opened file and digit

  1. sudo umount /media/box

ok perfect, so that we can mount the disk manually but every time we have to enter your username and password, we eliminate this "problem"

  1. sudo nano /etc/davfs2/secrets

and add this line

  1. https://dav.box.com/dav   yourusername   yourpassword

Now mount box.com without credentials, but a mount command is very long, we eliminate this "problem"

  1. sudo nano /etc/fstab

and add this line

  1. https://dav.box.com/dav /media/box davfs rw,noexec,noauto,user,async,_netdev,uid=pi,gid=pi 0 0

reboot system and you can simply mount the folder with

  1. sudo mount /media/box

Now we use rsync to make a backup with the command

  1. rsync -arHu --delete folderyouwantosave/ /media/box

The first backup will be slow (depending on your connection upload) and the next will be faster (incremental)

You can put the script in crontab every day/week even at night

Good backup

Nessun commento: