Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Cron pattern to copy over a USB drive

  • Re: NoSQL Offsite Backup

    Hi everyone, I see in the topic from above that is possible to insert a USB drive into the MangoES box and create a cron pattern that will copy automatically the files from the backup directory over the USB drive.

    I'm quite novice in this area and if anybody can help me with more information about how I can do this and how I can run this cron pattern it will be very helpful.

    Thank you!

  • Use rsync:
    Rsync can also delete the source files after they have been copied over if needed, however mango should do that for you if you've got a rolling backups of N days.
    Also take note you are better off making a bash script so you can run some checks. IE if the file system exists (the usb I mean)
    Make sure the bash script starts with


    Use to generate the cron pattern you'd like to use.
    Look at fstab for automatically mounting the USB file system and giving it a friendly name under mount if applicable - not necessary though

    Read up on that first and make sure everything lines up before restarting the mango , it can throw a spanner in the works if Linux doesn't like the fstab configuration.

    Once you've had a read I can assist further


  • Hi sky_watcher,

    You shouldn't have to worry about mounting the USB drive with fstab as Fox suggested - V3 Mango ES units have usbmount installed to facilitate the USB Utilities actions. It will mount the first USB stick plugged in at /media/usb0

    After that, your choices are

    1. Set Mango to backup directly to the USB drive instead of to the /opt/mango/backup folder. This is in the system settings
    2. Set up a cron pattern as Fox suggested and add that to a crontab either via crontab -e to invoke the script or simply add the script /etc/cron.daily/ (and then you don't need to generate the cron pattern but you have less control).
    3. Set a schedule in Mango and use event handlers to copy / move files as necessary.

  • Thanks Phil!
    Wasn't entirely sure on if fstab was applicable but felt it was good enough to mention for how a linux fs works at least.


  • True, it's applicable on any other Linux system - and you provided adequate notice that it's a bad place to make a mistake!

  • @phildunlap Hi Phil! Thanks for your advice.

    When I try to give that path to the backup directory I get an error:

  • Did you see over SSH or Webmin if the device is actually mounted there? It could also be a permissions issue, if Mango is running as a non-root user but that mounting point is owned by root. Check with ls -l /media/

  • @phildunlap On Mango I'm logged in with admin.

    The mounting point is owned by root.

  • Try chown'ing that to the 'mango' user like,

    sudo chown -R mango:mango /media/usb*

  • @phildunlap I don't have permission to change the owner for /media/usb0/. Could be a problem because the USB is mounted there?

  • I wouldn't think so. Did you sudo? What response did you get from running the command?

  • I edited the command, as there was no reason to give the mango user access to /media/boot/

  • This is the command and the error:


  • It could be caused by the filesystem type not supporting Linux permissions. Perhaps you could reformat the drive to an ext3 or ext4 filesystem?

  • @phildunlap I get same error in mango and the drive is formatted as ext4, is mounted and the mango user has wrights to write on the usb0 folder.


  • Hi guys, just gonna give a suggestion, cd into /media/usb0/
    then do the chown again

    sudo chown mango:mango . -R

    then enter the

    ls -la

    That should give us all info for that directory to start. Skywatcher, assuming you are using putty if you highlight the text, you can then paste into here with code tags.

    You should be able to create a file just with touch file
    no sudo required

  • Also ensure the mango user has at least read permissions to /media

  • @mattfox said in Cron pattern to copy over a USB drive:

    total 24
    drwxr-xr-x  3 mango mango  4096 Aug 29 14:54 .
    drwxr-xr-x 12 root  root   4096 Aug 29 11:45 ..
    drwx------  2 mango mango 16384 Aug 29 14:54 lost+found
    root@mangoES3324:/media/usb0$touch file
    root@mangoES3324:/media/usb0$la -ls
    total 16
     0 -rw-r--r-- 1 root  root      0 Aug 29 15:22 file
    16 drwx------ 2 mango mango 16384 Aug 29 14:54 lost+found

  • You're logged in as root, you need to be the mango user if you want to test effectively, also please use those code tags, it makes a lot easier to read.

    Edit: Thanks!
    Ok dir permissions look good. Try doing the touch newfile as mango, if you can do that, there should be no issues with mango creating files. I'll check my server for you soon if wanted to compare configs.


  • @mattfox

    file  lost+found
    mango@mangoES3324:/media/usb0$touch newfile
    file  lost+found  newfile
    mango@mangoES3324:/media/usb0$ls -la
    total 24
    drwxr-xr-x  3 mango mango  4096 Aug 29 15:43 .
    drwxr-xr-x 12 root  root   4096 Aug 29 11:45 ..
    -rw-r--r--  1 root  root      0 Aug 29 15:22 file
    drwx------  2 mango mango 16384 Aug 29 14:54 lost+found
    -rw-r--r--  1 mango mango     0 Aug 29 15:43 newfile