(ve):Backup and Restore Installed Packages
- This page was last modified on July 17, 2011, at 22:46.
From (mt) Community Wiki
Contents |
If you need to re-install the server and want to quickly have all of the installed packages on the server once again, you can perform the following steps on your Ubuntu server to backup and restore the installed packages. You will also want to backup the /etc/apt/sources.list file as this will contain a list of the repositories from which it can get you installed packages.
Backup Installed Packages
Here are the commands which you can execute as the root user via SSH:
cp /etc/apt/sources.list ~/sources.list dpkg --get-selections | grep install > ~/PackageList
Restore Installed Packages
To restore the installed packages, you will want to restore your backed up sources.list file to the /etc/apt/ directory on your Ubuntu server. Once this has been done, here are the commands for installing all of the packages which you previous installed via SSH as the root user:
apt-get update dpkg --set-selections < ~/PackageList apt-get install --yes dselect dselect update apt-get dselect-upgrade
Backup Installed Packages into Tarball
If you want to backup the files into a tarball, you will want to run this command via SSH as the root user:
mkdir ~/packages ; cp /etc/apt/sources.list ~/packages/sources.list ; dpkg --get-selections | grep install > ~/packages/PackageList ; tar zcvf ~/packages_`date +%m-%d-%Y`.tar.gz ~/packages/
With the tarball, you can save it locally for restoring at a later time.
Restore Installed Packages from Tarball
If you perform a re-installation of your (ve) with Ubuntu, you can upload the tarball to the root user's home directory '/root/' and run the following command:
tar zxvf ~/packages_*.tar.gz ; cp ~/packages/sources.list /etc/apt/sources.list ; apt-get update ; dpkg --set-selection < ~/packages/PackageList ; apt-get install --yes dselect ; dselect update ; apt-get dselect-upgrade
This will install all of the packages which you had at the time of the backup.