Linux, Open Source, Free Software, Bicycles, and other topics of interest.
RSS icon Twitter icon
  • Backup and Retrieve List of Installed Packages For Quick Software Restore in Linux

    Posted on November 13th, 2008 linuxandfriends No comments

    Why do you want to create a copy of the packages installed in Linux on your machine ? This is mainly to speed up in scenarios such as – upgrading from an earlier version to a newer version when you choose to do a fresh install, or installing an exact copy of Linux right down to all the packages installed on one machine to another machine and so on.

    The general steps to be followed are as follows :

    1. Get a copy of all the packages installed on your Linux machine (source machine) and save it to a text file.
    2. Copy the file to the target machine which has a fresh Linux install and merge it into the repository database.
    3. Finally run the command to do the upgrade.

    On a practical level, this is how it is done :

    Debian based Linux distributions

    In Debian Linux and other Debian based distributions such as Ubuntu which use dpkg and apt-get to do package management, this is how it is done.

    1. Get a copy of all the packages installed on the source machine and save it in the package.list.
      $ dpkg --get-selections > package.list
    2. Copy the file to the target machine and merge it to the repository database.
      dpkg --set-selections < package.list
    3. Finally upgrade the target system (You should have super user privileges to use apt-get. ).
      # apt-get dselect-upgrade

      apt-get will download and install all the packages that were listed in the package.list file.

    This way you get an exact copy of the packages installed on your source Linux machine.

    Arch Linux

    Arch Linux uses pacman tool for package management. In Arch Linux, you do it as follows :

    1. Backup the current list of packages on the source machine.
      $ pacman -Qqe > package.list
    2. Store the package.list file on a USB key or other convenient medium. Copy the package.list file to the new installation (target machine running Arch Linux), and navigate to the directory containing it.
    3. Install the packages using the following command :
      # pacman -S $(cat package.list)

    Related Posts

    Comments are closed.