Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- # Author: Nyle Davis Created 12-05-16
- # Purpose: Backup all installed package or Recover from backup
- # File: dpkg_backup.sh
- # Run this with command:
- # sudo bash ../Scripts/Backups/dpkg_backup.sh (options:
- # 1=mode=:backup, restore
- # 2=default, network or backup path)
- echo "DPkg Backup Processing Started! ";
- # Declare files and dirs
- $b_pth="/backups/Laptops/Aspire/";
- flname="${b_pth}/dpkg_backup_("`eval date +%Y-%m-%d`").txt";
- trname="${b_pth}/dpkg_backup_("`eval date +%Y-%m-%d`").tgz";
- ispath='/home/files/Installer Packages/dpkg-installs';
- # sc_pth="/home/ndavis/myfiles/Scripts/Backups"; Primary Path (from Aspire)
- sc_pth="/Scripts/Backups"; # Secondary Path (from DT)
- # Get arguments
- if [ "${b_pth}" != "/backups/Laptops/Aspire/" ]; then
- run_type=$1;
- cd "${path}";
- if [ ${2} = "default" ]; then
- path='/backups/Laptops/Aspire';
- elif [ ${2} = "network" ]; then
- path='/mnt/New_DT/backups/Laptops/Aspire';
- elif [ ${2} != "" ]; then
- path=${2};
- elif [ $1 = "" & $2 = "" ]; then
- echo "No option chosen! ";
- exit;
- fi
- else
- run_type="backup";
- path=${b_pth};
- fi
- # Run DPKG capture for all currently installed apps
- echo "Backing Up DPKG Apps! ";
- cd "${path}";
- if [ ${run_type} = "backup" ]; then
- rm -f ${flname};
- dpopt='--get-selections';
- dpkg ${dpopt} > ${flname};
- tar -czf ${trname} ${flname};
- rm -f ${flname};
- elif [ ${run_type} = "restore" ]; then
- dpopt='--set-selections';
- res_opts='& dselect install';
- dpkg ${dpopt} < ${flname} ${res_opts};
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement