What's new

Back up USB

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

sbsnb

Very Senior Member
My USB thumb drive recently failed in my RT-AC88U and took everything with it. I have another in there working, but I want to avoid the trouble in the future. I can't seem to figure out the best way to back it up. Since it's ext2, I can't just drop it in the PC and copy it. Since entware is on it I can't easily just back up the files in the router (they're in use). I need some way to automate periodic backups, but having a bit of trouble thinking of how.

It would be really cool if I could mirror one USB port to the other on the router at set intervals, like 24h or something. I couldn't find anything about backing up the USB drive(s) similar to how we back up JFFS.

Sorry for the new thread, but I wanted it to be reachable by searchers in the future.
 
My USB thumb drive recently failed in my RT-AC88U and took everything with it. I have another in there working, but I want to avoid the trouble in the future. I can't seem to figure out the best way to back it up. Since it's ext2, I can't just drop it in the PC and copy it. Since entware is on it I can't easily just back up the files in the router (they're in use). I need some way to automate periodic backups, but having a bit of trouble thinking of how.

It would be really cool if I could mirror one USB port to the other on the router at set intervals, like 24h or something. I couldn't find anything about backing up the USB drive(s) similar to how we back up JFFS.

Sorry for the new thread, but I wanted it to be reachable by searchers in the future.
To the pros: feel free to change/improve the script as i'm not an expert.
here is the crude script i wrote to backup my jffs and entware,
adjust paths as needed.
to restore one just needs to reverse paths ,
example : restore jffs from myusb backup folder
Code:
cp -ap /mnt/myusb/back-up-folder/jffs/. /jffs
Code:
#!/bin/sh
#/jffs/scripts/System-backup.sh
if [ -d "/tmp/mnt/MYUSB" ] && [ -d "/tmp/mnt/MYUSB2" ] && [ -d "/jffs" ]# check if source and destination folders are available
then
    # Things to do
    echo "BACKING-UP JFFS..." >> /tmp/syslog.log
    cp -ap /jffs/. /mnt/MYUSB2/RT-AC86U-BACKUP/jffs/ & "date" >> /mnt/MYUSB2/RT-AC86U-BACKUP/jffs-backup.log
    echo "BACKING UP ENTWARE" >> /tmp/syslog.log
    cp -ap /mnt/MYUSB/entware/. /mnt/MYUSB2/RT-AC86U-BACKUP/entware/ & "date" >> /mnt/MYUSB2/RT-AC86U-BACKUP/entware-backup.log
    echo "BACKUP COMPLETED." >> /tmp/syslog.log
else
    echo "Devices or Folder not found ,BACKUP WILL ABORT NOW! or i been robbed of my usb sticks" >> /tmp/syslog.log
fi

 cru a System-backup "0 */4 * * * /jffs/scripts/System-backup.sh"

#using cron to backup examples below
# cron jobs set up to backup every 4 hours.
# will log time and date when executed to a file

#cru a backup_jffs "0 */4 * * * cp -ap /jffs/. /mnt/MYUSB2/RT-AC86U-BACKUP/jffs/ & "date" >> /mnt/MYUSB2/RT-AC86U-BACKUP/jffs-backup.log"
#cru a backup_jffs "0 */4 * * * cp -ap /mnt/MYUSB/entware/. /mnt/MYUSB2/RT-AC86U-BACKUP/entware/ & "date" >> /mnt/MYUSB2/RT-AC86U-BACKUP/entware-backup.log"
 
Last edited:
It begs the question, what is easier, trying to recover entire filesystems or just reinitialize JFFS, reinstall AMTM, etc. and restore the few things you have customized?
 
rt-86u here. Me here too, my USB stick is quite old, I literally found an old one in a drawer and threw that in, so if it dies what do I do. Should I migrate it or what.

I think my logs and traffic stats are stored on the USB drive too, I'd like to keep that.
 
It begs the question, what is easier, trying to recover entire filesystems or just reinitialize JFFS, reinstall AMTM, etc. and restore the few things you have customized?
Recovering entire filesystems. Reconfiguring entware applications can be quite the task if you have extensive customizations. Remembering to back up each config as you edit them seems too error-prone. I'll forget that one time when it screws everything up.
 
here is the crude script i wrote to backup my jffs and entware,
adjust paths as needed.

Thanks. That script doesn't complain or skip files in use at the time copy is initiated?
 
It begs the question, what is easier, trying to recover entire filesystems or just reinitialize JFFS, reinstall AMTM, etc. and restore the few things you have customized?
depends in how much customization you have .
I my case i would take to long to configure the router from fresh, to many custom scripts etc/ losing my diversion blacklist/whitelist alone that i accumulated over the years would be a disaster.
i wrote the script because the rt-ac-86u has a bug that sometimes corrupts the usb when rebooted.
last time it took me 10 minutes to restore the whole thing.
 
Thanks. That script doesn't complain or skip files in use at the time copy is initiated?
it only complains if it cant find the source/destination folders.
 
Try use scp to transfer to a 550MB tar file of /mnt/sda1 to the PC, but it just hangs at about 88% with RAM usage at 100%. Looks like scp can't handle transferring more than available RAM for some reason.
 
I need some way to automate periodic backups
It would be really cool if I could mirror one USB port to the other on the router at set intervals, like 24h or something. I couldn't find anything about backing up the USB drive(s) similar to how we back up JFFS.

For backing up router script stuff my idea would be to buy two identical 16 GB device (Sandisk is good), format properly with AMTM, and for backup just manually clone the disk using dd. After cloning the source disk unplug the target disk and keep as offline backup. Surely you wouldn’t need to do that more than once a month anyway. I can’t see the sense in automatic backup because it would require leaving the backup target be permanently attached to the router where it could be corrupted

If we’re talking about backing up large drives of media files just keep formatted NTFS and backup to your computer.

https://www.tecmint.com/clone-linux-partitions/
 
I have a Synology NAS which has a built in server backup tool based on rsync.
I have it taking nightly snapshots with 1 year of continuity.
Even if you don’t have a Synology to do this, rsync may solve the scp issue mentioned above and give you some level useful intelligent copying (I too have seen some scp oddities over the years and have also installed sftp as a result and another alternative to copy files on/off).
Obviously rsync and sftp would need to be installed via entware.

I don’t know what the worry is with in use files, I’ve never seen anything complain about taking a copy of a file that is open or being edited in Linux-land, it’s designed that way!


Sent from my iPhone using Tapatalk
 
It would be really cool if I could mirror one USB port to the other on the router at set intervals, like 24h or something. I couldn't find anything about backing up the USB drive(s) similar to how we back up JFFS.

rsync will do that, just set it up as a cru job every night.

If your backup USB drive just have 2 folders called USB and JFFS you can run 2 jobs, 1 to sync the live USB and one for the JFFS partition into those folders.




Sent from my iPhone using Tapatalk
 
I thought rsync could only work at the filesystem level rather than at the device level. I'm wanting to mirror the device, block by block ... even the partition tables. etc.
 
I thought rsync could only work at the filesystem level rather than at the device level. I'm wanting to mirror the device, block by block ... even the partition tables. etc.

Correct, but then you exclude the jffs backup issue as well.

Block sync of 2 USB’s could likely be done with dd however not incrementally and so the amount of writes you’ll be doing on the slave drive will likely shorten its life anyway.

I’d just rsync the important bits for recovery and be done with it. You shouldn’t be keeping any important files not held elsewhere on a USB drive hung off a router anyway, so just backing up the routers own important bits should be the only concern.


Sent from my iPhone using Tapatalk
 
Since I have a FreeNAS system on the LAN I'll probably rsync it there. If a ZFS RAID-Z2 system can't keep the data reliably, then I'm in a bigger world of hurt. Thanks to everyone.
 
  • Like
Reactions: JDB
OK. It occurs to me that although I have rsync working fine to back up /jffs and /mnt/entware to my FreeNAS system, I have no recovery plan in the event that things go badly. What's the best way to get these backups back onto the router in a way that "just works" in the event of some sort of failure? Getting the physical files there is no problem, but what do I have to do to get all the software to start using those files as before?

I can't overwrite files in use, so it seems like I couldn't just set up the router fresh and then copy over files.
 
Wouldn't it be nice to have some sort of image backup facility. I wonder if this is possible. Copying files back always borks something like permissions. Imaging would be so much better. Can't JFFS already be backed up to a TAR file?
 
I think /jffs is not generally in-use all the time, so restoring it should be as easy as using rsync backwards and rebooting. I'm thinking I'd be able to ./rc.unslung stop and restore /entware and ./rc.unslung start to restore the flash drive. I guess we'll find out when and if that happens.
 
There are lots and lots of free utilities out there that will take a snapshot of your entire USB stick and allow you to image it back as required. Just eject it now and then whenever you do a major update and take a new snapshot.
 
And those utilities run under the asuswrt environment so they can be automated? I'm not interested in unplugging the USB and taking an image of it all the time.
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top