Backup and restore

  • This how-to describes the method for using OpenWrt file-level backup/restore.
  • Follow Preserving packages to include user-removed/installed packages in your backup.
  • Follow Preserving configuration to determine whether to keep the settings.
  • Follow Generic backup for block-level backup/restore.
  • Extroot or additional overlay setups require extra measures.
  • Back up and restore OpenWrt configuration.

Customize your backup configuration.

  1. Navigate to LuCI → System → Backup / Flash Firmware → Configuration.
  2. Add/remove files/directories and click Submit when done editing.
  3. Click Open list… button to view the list of files for backup.

Make sure the list contains all the files you want to save.

Back up OpenWrt configuration to local PC.

  1. Navigate to LuCI → System → Backup / Flash Firmware → Actions: Backup.
  2. Click Generate archive button to download the archive.

Restore previously saved OpenWrt configuration from local PC.

  1. Navigate to LuCI → System → Backup / Flash Firmware → Actions: Restore.
  2. Click Choose File button to select the archive.
  3. Click Upload archive… button to upload the archive.

OpenWrt provides Sysupgrade utility for file-level backup/restore.

Customize and verify your backup configuration.

# Add files/directories
cat << EOF >> /etc/sysupgrade.conf
/etc/sudoers
/etc/sudoers.d
EOF
 
# Edit backup configuration
vi /etc/sysupgrade.conf
 
# Verify backup configuration
sysupgrade -l

Back up OpenWrt configuration to local PC.

# Generate backup
umask go=
sysupgrade -b /tmp/backup-${HOSTNAME}-$(date +%F).tar.gz
ls /tmp/backup-*.tar.gz
 
# Download backup
scp root@openwrt.lan:/tmp/backup-*.tar.gz .

Restore previously saved OpenWrt configuration from local PC.

# Upload backup
scp backup-*.tar.gz root@openwrt.lan:/tmp
 
# Restore backup
ls /tmp/backup-*.tar.gz
sysupgrade -r /tmp/backup-*.tar.gz

Manually removed/installed packages are not preserved by default.

Use sysupgrade -k or Opkg extras to include user-removed/installed packages in your backup.

Set up Hotplug extras to automatically restore Opkg profile after upgrade.

The files preserved on system upgrade include the following locations:

# Automatically detected modifications
opkg list-changed-conffiles
 
# System configurations supplied by individual packages
grep -r -e . /lib/upgrade/keep.d
 
# User configuration to edit if necessary
grep -e . /etc/sysupgrade.conf
 
# Obsolete settings no longer supported
uci show luci.flash_keep

This should cover most configurations by default, including the ones in /etc/config.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2021/10/19 22:26
  • by vgaetera