Create Project Need help?
Show more (1)
Antoni Gendrau

Backup your data with Raspberry pi

Status: Proposal
February 17, 2013

As Murphy's Law says, there are two type of users: those who have lost data and those who are about to lose data. To prevent a second event of this type (can you guess which type of user I am?), I have built a NAS (Network Attached Storage) composed by a 2-TBytes USB hard disk and a Raspberry pi, which connects the hard disk to my home network via Ethernet.


  • Uses as a mass storage system an USB hard drive, much cheaper than one with Ethernet interface.
  • One side of the Raspberry pi (USB) is connected to the hard disk, and the other side (Ethernet) to the network. No need to talk about the benefits of Raspberry Pi. Just mention that consumes far less than an old computer used for this purpose, and its price is negligible compared to the hard disk.
  • The Raspberry Pi, the hard drive with its USB interface and the on-off circuitry fit in a compact case.
  • “Samba” network interface. Any backup program can be used. There are many of them "open source".
  • The original part of this design is that power can not be forgotten switched on, because when not in use automatically switches off, keeping consumption = 0 (not even stand-by consumption).


How it works (from the user point of view):
To start the system, simply push de ON button. Green LED lights on.
After one minute or so, Linux starts and the yellow LED lights on. That means that the system is ready, and the hard disk can be seen across the network.
If the red LED blinks, that means that there is transfer data.
After 15 minutes without using the unit, the system shuts down, but 5 minutes before that, the yellow LED starts blinking to indicate that shut down is near.
“Without using the unit” means that no transfer data is done, and there are no files opened by remote applications.
There are some extra functions:
Pressing the OFF button shortly, the system does exactly the opposite than expected: never shuts down. To indicate this situation, the yellow LED blinks slowly.
Pressing the OFF button more than one second, the yellow LED starts blinking fast, and  the system shuts down immediately, or as soon as the unit is not being used.



To install the software you must follow this steps:
  • Install the last Raspbian “wheezy” as explained in:
  • It’s a good idea to set the Raspberry pi with a fixed IP address. Then, you can find the board from windows explorer faster than looking for it by it’s name.
    I chose because is in the same range that the adress given by my router.
    To do this, you must edit the file interfaces as follows:
    $ cd /etc/network
    $ sudo nano interfaces

    replace the line “iface eth0 inet dhcp” with:

        iface eth0 inet static
  • Now, you must create a directory where the external USB drive will be mounted, and edit the file fstab to mount it automatically each time system starts. I selected the name backup for that directory.

    $ sudo mkdir /media/backup
    $ cd /etc
    $ sudo nano fstab

    add at the end of the file:
    /dev/sda1 /media/backup auto users,uid=1000,gid=100,utf8,dmask=027,fmask=137 0 0
  • You must install the samba filesystem and edit the configuration file smb.conf:

    $ sudo apt-get install samba smbfs

    More information in:

    $ /etc/samba
    $ sudo nano smb.conf

    Add at the end of the file:

        comment = Public
        read only = no
        locking = no
        path = /media/backup
        guest ok = yes
        force user = pi
        create mask 0777
        directory mask 0777
  • You must install the utilities that allows you to manage the Input/Output bits present in the Raspberry pi connector.
    Basically, it’s done by:

    $ sudo apt-get install git-core

    A complete information can be found in:
  • The monitor program uses the utility lsof that must be installed too.

    $ sudo apt-get install lsof

    More information in:
  • Besides  all Linux installation, the central part of the design is a program called nasmonitor that monitorizes the hard disk activity. After some time not being used, the monitor shuts down the system. I installed it in the directory /home/apli. Now, it’s necessary to tell the system to run this program after each start-up.

    $ cd /etc
    $ sudo nano rc.local

    add at the end of the file:


Photos description:

Front view
- On and Off Buttons
- Power connector (12V).
- Ethernet Connector
- Power LED (green)
- Hard drive activity LED (red)
- Status LED (yellow)
- Fan
The Activity LED indicates normal operation (fixed) or imminent shutdown (blinking).
The fan has been salvaged from an old video card. Despite the low power consumption, the original box, completely closed, reached dangerous temperatures
Internal view
On the front is the keypad.
At the bottom is the hard drive. Above, a prototype board that supports the Raspberry Pi and the hard disk USB interface.
The Raspberry Pi is upside down mounted. It’s not very elegant in this position, but since it doesn’t have anchor holes, this system permits a good attachment to a female base conector welded on the prototype board.
The hard disk USB interface is removed from its original box, and it is also mounted upside down to allow the short orginal wires reach the hard disk and, in turn, reduce the length of the case needed to locate the assembly
The transistors may be a little oversized, with only one LED to drive. I chose them simply because mounted in this way, they are completely flat.


Read the full post
Show less
Internal view
Front view

Loading comments...