Raspberry Pi project

62 views
Skip to first unread message

Andy Harsley

unread,
Aug 10, 2012, 9:12:26 AM8/10/12
to notti...@googlegroups.com
Since I live of a flash drive these days, I'm looking for an auto-backup device. Basically something cheap and standalone that I pop the drive into when I get home and it dumps a copy whilst I put the kettle on - then ideally it switches itself off.

I'm thinking that a RasPi with a big SD card would be an ideal solution. A model 'B' would allow me to network in if I lost my drive (or it died on me, which has happened twice), but otherwise it would just sit there running off a PP3.

So:

a) does anyone know if such a thing already exists?
b) would anyone be interested in having a go at programming a Pi to do the job?

(If Pi ran M$ windows I could do it myself, but sadly I never found the time to get into Linux.)

I'm sure I'm not the only one who would find such a thing useful.

andy

Jake Howe

unread,
Aug 11, 2012, 4:48:26 AM8/11/12
to notti...@googlegroups.com
Hi Andy,

I am probably not the best person to answer it, but thought I would try and get the ball rolling for you. There could be a simple command like 'cp file file2'That could be set to run automatically, however that is a little out of my depth.

I have used a utility called Rsync before - http://en.wikipedia.org/wiki/Rsync

The utility is specifically for copying files over a network (thats what I used it for) however I imagine it could be set to transfer files locally. Whats great about it is it only copies across new/changed files, so you do not get a complete copy process every time. Even if there is a better solution for direct system transfers, rsync could be handy to have files automatically backed up to a windows machine on the network.

There is a long list of programs for different platforms, with slightly different uses on the wiki also, which takes some of the command line fear out of setting it up on linux, However those programs might not work as well on the Pi.

*disclaimer - I do not use linux on a daily basis, I was a linux user for about a year before I bought my first Mac, I have hardly touched my Pi apart from making fancy cases for it *

Jake

deejak

unread,
Aug 12, 2012, 3:54:25 AM8/12/12
to notti...@googlegroups.com
Rsync is an excellent utility for this sort of thing. It is particularly good for transferring over a slow link, as the algorithm used identifies, and transfers, only those parts of each file which have changed. To do this, though, it needs a processor at each end of the link. Mac OSX apparently comes with rsync as standard.

However, it can be told to copy local files without using the rsync algorithm - just identifying changed files using datestamps, etc. The rsync command line options are extremely extensive, and although I have experience in a Windows & Linux environment, I wouldn't like to advise re Mac.

You might find http://www.maclawstudents.com/blog/techniques/automatic-backups-to-usb-flash-drives/ useful.

David Clarke.
Message has been deleted

Mark Steward

unread,
Aug 12, 2012, 10:16:48 AM8/12/12
to notti...@googlegroups.com
Interesting backstory:



BTW, be careful with rsync - a lot of people recommend --delete, but this can obviously be destructive.  Also, don't just check the timestamp - there are a lot of cases where Windows apps don't update the modified date.


Mark

On Sun, Aug 12, 2012 at 3:05 PM, Adam Hillson <adam.h...@gmail.com> wrote:
Windows can test in a similar way, if exist g:\NUL

NUL always exists on a drive, if its not there - the drive isnt.


On Saturday, August 11, 2012 3:59:45 PM UTC+1, Patrick J wrote:
Andy,
Linux/unix shell scripts can do this for you very easily.  If you're only familiar with Windows, these are text files with multiple command lines in them like .cmd or .bat files.

However, shell scripts are very adaptable and are what run a whole lot of the linux system behind the scenes.

Linux shell allows you to test for the presence of a file with something like "if -f /media/usb0".   Something like that could spot your plugged in flash drive (I'm guessing at syntax/paths as I'm not near a linux login).  Then it could execute "cp -R /media/usb0 /home/pi/backups/`date`/".  The -R means that it would recursively copy every sub-directory and file.  The date command would probably want some parameters to make it easy to read. 
I think there is an additional flag you can use to create the new destination directory or you could just use a mkdir command to make the directory separately.  If the if statement evaluates as false, simply put a wait statement for 2 seconds.  Enclose these few lines in a never ending loop and run the program.  You can add the shell program name into the init sequence so that it is always running.

Maybe 10 lines of shell to get this working.

Patrick

Michael Erskine

unread,
Aug 12, 2012, 4:31:32 PM8/12/12
to notti...@googlegroups.com

When the memory stick is plugged in it is by definition the latest version and so the rsync command line (or whatever you choose to use)     should be  written accordingly. The use of rsync is to reduce the amount of unnecessary copying, it's not meant to be some sort of magic - just read the man page and test your assumptions, and you can't go too far wrong.

Jake Howe

unread,
Aug 12, 2012, 4:47:12 PM8/12/12
to notti...@googlegroups.com
I used rsync for months between two Macs, and never had a single issue. Its not like I was dealing with a pen drive either, this was big clumsy design files.

Jake

Matt Spandex

unread,
Aug 13, 2012, 1:56:12 AM8/13/12
to notti...@googlegroups.com
On 12 Aug 2012, at 15:16, Mark Steward <marks...@gmail.com> wrote:

Interesting backstory:



BTW, be careful with rsync - a lot of people recommend --delete, but this can obviously be destructive.  Also, don't just check the timestamp - there are a lot of cases where Windows apps don't update the modified date.

Recommend rdiff-backup for this kind of thing. Reverse incremental backups. Very nifty.

Matt

Michael Erskine

unread,
Aug 13, 2012, 4:07:16 AM8/13/12
to nottinghack
Andy,

If you have a hsnotts wiki editing account you can start a project
page where the various items for discussion can be properly managed. A
project page would be most useful for people finding this thread from
google searches even if we are porting something simple like the
following to the Pi...

http://andrioid.net/tech/linux/usb-backup

...I think this does exactly what you are looking for but what people
want to see (including yourself!) is the Pi specifics, you experiences
(especially if it just works!) and best of all, pictures! A project
page will also direct people to our excellent wiki!

Michael.
Reply all
Reply to author
Forward
0 new messages