Skip to content

Instantly share code, notes, and snippets.

@obatiuk
Created April 2, 2018 05:04
Show Gist options
  • Save obatiuk/1a0efb6c5ac0dfed8349ca96c0cf647c to your computer and use it in GitHub Desktop.
Save obatiuk/1a0efb6c5ac0dfed8349ca96c0cf647c to your computer and use it in GitHub Desktop.
#!/bin/sh
[ -n "$(echo $@ | grep "\-debug")" ] && set -x
date=$(date +%Y-%m-%d-T%H-%M-%S)
host=$(cat /proc/sys/kernel/hostname)
backup_dir="/tmp/${host}-${date}"
mkdir -p ${backup_dir}
# backup installed package list to backup dir
# to restore packages do:
# cat backup-packages* | cut -f 1 -d ' ' | while read PACKAGE; do echo $PACKAGE; done;
opkg list-installed > ${backup_dir}/backup-packages-${host}-${date};
# create config files backup using sysupgrade tool
sysupgrade --create-backup ${backup_dir}/backup-sysupgrade-${host}-${date}.tar.gz;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment