# Auto Schedule Backup?

**URL:** <https://community.openenergymonitor.org/t/auto-schedule-backup/5189>\
**Category:** emonSD\
**Created:** [24 September 2017 19:21 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189 "2017-09-24T19:21:11Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![a52346](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/a/b19c9b/32.png) [@a52346](https://community.openenergymonitor.org/u/a52346)\
**Post date:** [24 September 2017 19:21 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/1 "2017-09-24T19:21:11Z")

</div>

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?

Cheers!

---

<div class="post-metadata">

**Author:** ![ian](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://community.openenergymonitor.org/u/ian)\
**Post date:** [24 September 2017 20:47 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/2 "2017-09-24T20:47:36Z")

</div>

Have a look at this thread

> [@Emoncms Backup Methods](https://community.openenergymonitor.org/t/emoncms-backup-methods/1269):
>
> Hi Glyn Thanks. I am using the emonSD-03May16- RELEASE image which is running read-only so it looks as if I am good to go. I will not bother with the hard drive. Paul Reed updated his dropbox archive software so it runs on an emonpi taking care of the need to switch to read write and back again. I asked him if his tar.gz file was compatible with your backup tar.gz file because it it was re-instating a running system in the event of an SD failure would be very easy and quick. He was not sure b…

---

<div class="post-metadata">

**Author:** ![a52346](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/a/b19c9b/32.png) [@a52346](https://community.openenergymonitor.org/u/a52346)\
**Post date:** [24 September 2017 21:17 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/3 "2017-09-24T21:17:37Z")

</div>

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.

Cheers!

---

<div class="post-metadata">

**Author:** ![ian](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://community.openenergymonitor.org/u/ian)\
**Post date:** [25 September 2017 06:42 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/4 "2017-09-25T06:42:47Z")

</div>

Sorry. Start from here.

[GitHub - Paul-Reed/dropbox-archive: Upload emoncms data to Dropbox](https://github.com/Paul-Reed/dropbox-archive)

Ian

---

<div class="post-metadata">

**Author:** ![Pukka](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/p/d07c76/32.png) [@Pukka](https://community.openenergymonitor.org/u/Pukka)\
**Post date:** [26 September 2017 08:57 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/5 "2017-09-26T08:57:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ian](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://community.openenergymonitor.org/u/ian)\
**Post date:** [26 September 2017 18:56 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/6 "2017-09-26T18:56:57Z")

</div>

Hi

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.

Ian

---

<div class="post-metadata">

**Author:** ![Pukka](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/p/d07c76/32.png) [@Pukka](https://community.openenergymonitor.org/u/Pukka)\
**Post date:** [26 September 2017 19:20 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/7 "2017-09-26T19:20:21Z")

</div>

Hi Ian

Do you mind sharing how?

Paul

---

<div class="post-metadata">

**Author:** ![Paul](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/paul/32/28_2.png) [@Paul](https://community.openenergymonitor.org/u/Paul)\
**Post date:** [27 September 2017 12:44 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/8 "2017-09-27T12:44:30Z")

</div>

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)

![pid](https://community.openenergymonitor.org/uploads/default/original/2X/2/282201dd75d7656715cf2272f44416647a180b57.PNG)

Paul

```auto
[{"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":[[],[],[]]}]

```

---

<div class="post-metadata">

**Author:** ![Pukka](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/p/d07c76/32.png) [@Pukka](https://community.openenergymonitor.org/u/Pukka)\
**Post date:** [27 September 2017 13:23 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/9 "2017-09-27T13:23:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![maurice1](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/m/50afbb/32.png) [@maurice1](https://community.openenergymonitor.org/u/maurice1)\
**Post date:** [7 November 2018 14:55 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/10 "2018-11-07T14:55:48Z")

</div>

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/emoncms-export.sh  
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 ?  
Regards  
M

---

<div class="post-metadata">

**Author:** ![Pukka](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/p/d07c76/32.png) [@Pukka](https://community.openenergymonitor.org/u/Pukka)\
**Post date:** [9 November 2018 22:50 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/11 "2018-11-09T22:50:07Z")

</div>

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?

Paul

---

<div class="post-metadata">

**Author:** ![ian](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://community.openenergymonitor.org/u/ian)\
**Post date:** [10 November 2018 06:53 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/12 "2018-11-10T06:53:18Z")

</div>

You might be interested in this;

> **[GitHub - Paul-Reed/dropbox-archive: Upload emoncms data to Dropbox](https://github.com/Paul-Reed/dropbox-archive)**
>
> Upload emoncms data to Dropbox. Contribute to Paul-Reed/dropbox-archive development by creating an account on GitHub.

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.

Ian

---

<div class="post-metadata">

**Author:** ![Pukka](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/p/d07c76/32.png) [@Pukka](https://community.openenergymonitor.org/u/Pukka)\
**Post date:** [12 November 2018 08:41 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/13 "2018-11-12T08:41:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Paul](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/paul/32/28_2.png) [@Paul](https://community.openenergymonitor.org/u/Paul)\
**Post date:** [12 November 2018 11:41 UTC](https://community.openenergymonitor.org/t/auto-schedule-backup/5189/14 "2018-11-12T11:41:27Z")

</div>

Since October 2017 I’ve [been using this backup solution](https://gist.github.com/Paul-Reed/c29cfa755fed666805956eb6da42a0d0) using node-red, and with this flow Dropbox will store 30 days worth of backups (even with a free account)

Paul
