Auto Schedule Backup?

(Al P) #1

Hi. How would I go about scheduling a daily backup and then either ftping it off to a network share? or copying it to an NFS mount,

My backup file as created using the Backup menu item is 250MB.

I guess it would be best to create the file in a RAM disk or an attached USB stick rather than write this to the SD card each day?


(ian) #2

Have a look at this thread

(Al P) #3

Thanks Ian, I must be missing something - that thread seems to start in the middle of a conversation, and appears to be discussing the development of the backup script?

I’d like to have the script run automatically each day.


(ian) #4

Sorry. Start from here.


(Paul) #5

I have added this and i can manually run the code, I tried to add it is a cron job but i am unable to get it to run, also this morning the cron job is no longer listed. even tho i ran rpi-rw before hand.

(ian) #6


I can’t help you with that. I used the node red installed with emoncms and set up a daily flow to run the script. Works a treat.


(Paul) #7

Hi Ian

Do you mind sharing how?


(Paul Reed) #8

Just import the flow below into node-red, check that the path to dropbox-archive is correct in the exec node, and the backup should run every night at 1.30am (or whatever time you want).

To test - click the inject node, but make sure that you don’t click a second time whilst the first click is still in progress (you can see the PID on the screenshot indicating that it’s still running)



[{"id":"c708b992.38f748","type":"comment","z":"7fc7e6a6.803818","name":"Emoncms data backup","info":"Data backud up to /home/pi/emoncmsbackup to either backup1 or backup2 (depending upon the day!)","x":107.5,"y":192,"wires":[]},{"id":"1b89faf8.849ab5","type":"inject","z":"7fc7e6a6.803818","name":"Start>","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"30 01 * * *","once":false,"x":108,"y":245,"wires":[["f8c1a39c.7124f"]]},{"id":"f8c1a39c.7124f","type":"exec","z":"7fc7e6a6.803818","command":"sudo php /home/pi/dropbox-archive/backup.php","addpay":false,"append":"","useSpawn":"","timer":"","name":"Upload emoncms data to Dropbox","x":346,"y":244.5,"wires":[[],[],[]]}]

(Paul) #9

Hi Paul

Thanks for this, i was about 90% of the way. i had the command as /home/pi/data/dropbox/ php backup.php which is wrong.

(maurice) #10

I have looked at auto backup to usb stick for a while and read about the different propositions.

I went with
$df -h
to find out my usb drive letters sda1

Then i mounted it
$sudo mount -t vfat /dev/sda1 /mnt/usb/ -o uid=1000,gid=100,utf8,dmask=027,fmask=137

Then I
crontab-e to edit cron

I added
0 4 * * 1 /home/pi/backup/
0 5 * * 1 mv /home/pi/data/emoncms-backup* /mnt/usb/Backup/

Is there any reason why restoring this wouldn’t work if pi died, providing I copied the emoncms-backup-2018****.tar.gz back to /home/pi/data/emoncms-backup ?

(Paul) #11

Backing up to a USB stick sounds a much better option. could a scheduled time and usb device be added in to the backup section?


(ian) #12

You might be interested in this;

Works a treat. And I am pretty sure the file produced is the same as the file created by the built in backup command in emoncms.


(Paul) #13

I have used this before and it worked ok. they is just a problem with where it stores the backup in the file system so it fills the SD card and it would only store 5 days on dropbox.

An official backup to usb memory stick would be good, as we could then store many backups on a 16gb usb

(Paul Reed) #14

Since October 2017 I’ve been using this backup solution using node-red, and with this flow Dropbox will store 30 days worth of backups (even with a free account)