Generate the shortest possible apt-get install command to duplicate installation?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite
1












As part of a larger backup-restore scheme, I'm trying to get a concise list of an ubuntu 16.04 server's installed packages. I want the list to be as short as possible and potentially be useful even five years later on a new LTS version of ubuntu.



Consider the following scenario:



Day 1: I install ubuntu 16.04 server on a machine.



Day 2: I install php-fpm



Day 3: I install nginx, php, and sendmail



Day 4: I install atanks. No, I don't know why I'm installing a graphical game on a headless server. The point is just to add more stuff which was manually installed to apt's database.



Day 5:
My server explodes in a fiery inferno. Maybe a tank explosion had something to do with it. In any case, I need to create a new server based on the backup.



In my backup script, I'd like to be able to generate the following line based on my apt-get activity over the past few days:



apt-get install atanks nginx php php-fpm sendmail


So how do we do that?



First, I tried some apt queries,



apt-mark showmanual


but they seemed to list hundreds of packages more than I had manually installed.



Second, I found debfoster:



Right after installing ubuntu, I'd run:



sudo apt-get update
sudo apt-get -y install debfoster
sudo debfoster -q
sudo cp /var/lib/debfoster/keepers ~/startkeepers


And normal server operations could continue. I or other users of the server might install any number of packages.



In my backup script, I'd have the following:



sudo debfoster -q
sudo echo $(diff --new-line-format="" --unchanged-line-format="" /var/lib/debfoster/keepers ~/startkeepers) > apt-get.list


And then I could restore on a new install with:



apt-get install -y $(cat apt-get.list)


Unfortunately, this method isn't working perfectly due to different packages either installing or not installing certain reccommends.



When after storing startkeepers, I run



sudo apt-get install -y nginx php-fpm python-certbot-nginx sendmail composer php-mbstring php-xml php-zip php-mysql
sudo debfoster -q
sudo echo $(diff --new-line-format="" --unchanged-line-format="" /var/lib/debfoster/keepers ~/startkeepers) | tr ' ' 'n'


This last line has the following output:



composer
php-fpm
php-mbstring
php-mysql
php-xml
php-zip
python-certbot-nginx
sendmail


This is missing... nginx!!! That freaked me out, but then I realized that nginx must be a dependency of python-certbot-nginx, and I confirmed that. So maybe this method would work after all?



I ran sudo apt-get upgrade on my test server and the output remained unchanged after using



sudo debfoster -q
sudo echo $(diff --new-line-format="" --unchanged-line-format="" /var/lib/debfoster/keepers ~/startkeepers) | tr ' ' 'n'


However, on my real server, the one I'm trying to configure this scripted duplication for, there are an additional two lines in it that I don't think should be there:



linux-headers-4.4.0-112-generic
linux-image-4.4.0-112-generic


I didn't manually install those... And don't want to install them on another server, unless whoever determined they were necessary does so again. Could it have been apt-update?



TLDR; What's a reliable way to keep track of a server-version agnostic list of manually installed packages, where manually means stuff the user knows about installing, not were installed by upgrades or however linux headers and kernel versions get installed? Anything that improves my process would be appreciated, bonus points for using apt tools instead of debfoster, considering its developers claim apt supports all of its features.










share|improve this question























  • The reliable way is to write down the list of programs as you install them.
    – dsstorefile1
    Feb 27 at 6:29














up vote
1
down vote

favorite
1












As part of a larger backup-restore scheme, I'm trying to get a concise list of an ubuntu 16.04 server's installed packages. I want the list to be as short as possible and potentially be useful even five years later on a new LTS version of ubuntu.



Consider the following scenario:



Day 1: I install ubuntu 16.04 server on a machine.



Day 2: I install php-fpm



Day 3: I install nginx, php, and sendmail



Day 4: I install atanks. No, I don't know why I'm installing a graphical game on a headless server. The point is just to add more stuff which was manually installed to apt's database.



Day 5:
My server explodes in a fiery inferno. Maybe a tank explosion had something to do with it. In any case, I need to create a new server based on the backup.



In my backup script, I'd like to be able to generate the following line based on my apt-get activity over the past few days:



apt-get install atanks nginx php php-fpm sendmail


So how do we do that?



First, I tried some apt queries,



apt-mark showmanual


but they seemed to list hundreds of packages more than I had manually installed.



Second, I found debfoster:



Right after installing ubuntu, I'd run:



sudo apt-get update
sudo apt-get -y install debfoster
sudo debfoster -q
sudo cp /var/lib/debfoster/keepers ~/startkeepers


And normal server operations could continue. I or other users of the server might install any number of packages.



In my backup script, I'd have the following:



sudo debfoster -q
sudo echo $(diff --new-line-format="" --unchanged-line-format="" /var/lib/debfoster/keepers ~/startkeepers) > apt-get.list


And then I could restore on a new install with:



apt-get install -y $(cat apt-get.list)


Unfortunately, this method isn't working perfectly due to different packages either installing or not installing certain reccommends.



When after storing startkeepers, I run



sudo apt-get install -y nginx php-fpm python-certbot-nginx sendmail composer php-mbstring php-xml php-zip php-mysql
sudo debfoster -q
sudo echo $(diff --new-line-format="" --unchanged-line-format="" /var/lib/debfoster/keepers ~/startkeepers) | tr ' ' 'n'


This last line has the following output:



composer
php-fpm
php-mbstring
php-mysql
php-xml
php-zip
python-certbot-nginx
sendmail


This is missing... nginx!!! That freaked me out, but then I realized that nginx must be a dependency of python-certbot-nginx, and I confirmed that. So maybe this method would work after all?



I ran sudo apt-get upgrade on my test server and the output remained unchanged after using



sudo debfoster -q
sudo echo $(diff --new-line-format="" --unchanged-line-format="" /var/lib/debfoster/keepers ~/startkeepers) | tr ' ' 'n'


However, on my real server, the one I'm trying to configure this scripted duplication for, there are an additional two lines in it that I don't think should be there:



linux-headers-4.4.0-112-generic
linux-image-4.4.0-112-generic


I didn't manually install those... And don't want to install them on another server, unless whoever determined they were necessary does so again. Could it have been apt-update?



TLDR; What's a reliable way to keep track of a server-version agnostic list of manually installed packages, where manually means stuff the user knows about installing, not were installed by upgrades or however linux headers and kernel versions get installed? Anything that improves my process would be appreciated, bonus points for using apt tools instead of debfoster, considering its developers claim apt supports all of its features.










share|improve this question























  • The reliable way is to write down the list of programs as you install them.
    – dsstorefile1
    Feb 27 at 6:29












up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





As part of a larger backup-restore scheme, I'm trying to get a concise list of an ubuntu 16.04 server's installed packages. I want the list to be as short as possible and potentially be useful even five years later on a new LTS version of ubuntu.



Consider the following scenario:



Day 1: I install ubuntu 16.04 server on a machine.



Day 2: I install php-fpm



Day 3: I install nginx, php, and sendmail



Day 4: I install atanks. No, I don't know why I'm installing a graphical game on a headless server. The point is just to add more stuff which was manually installed to apt's database.



Day 5:
My server explodes in a fiery inferno. Maybe a tank explosion had something to do with it. In any case, I need to create a new server based on the backup.



In my backup script, I'd like to be able to generate the following line based on my apt-get activity over the past few days:



apt-get install atanks nginx php php-fpm sendmail


So how do we do that?



First, I tried some apt queries,



apt-mark showmanual


but they seemed to list hundreds of packages more than I had manually installed.



Second, I found debfoster:



Right after installing ubuntu, I'd run:



sudo apt-get update
sudo apt-get -y install debfoster
sudo debfoster -q
sudo cp /var/lib/debfoster/keepers ~/startkeepers


And normal server operations could continue. I or other users of the server might install any number of packages.



In my backup script, I'd have the following:



sudo debfoster -q
sudo echo $(diff --new-line-format="" --unchanged-line-format="" /var/lib/debfoster/keepers ~/startkeepers) > apt-get.list


And then I could restore on a new install with:



apt-get install -y $(cat apt-get.list)


Unfortunately, this method isn't working perfectly due to different packages either installing or not installing certain reccommends.



When after storing startkeepers, I run



sudo apt-get install -y nginx php-fpm python-certbot-nginx sendmail composer php-mbstring php-xml php-zip php-mysql
sudo debfoster -q
sudo echo $(diff --new-line-format="" --unchanged-line-format="" /var/lib/debfoster/keepers ~/startkeepers) | tr ' ' 'n'


This last line has the following output:



composer
php-fpm
php-mbstring
php-mysql
php-xml
php-zip
python-certbot-nginx
sendmail


This is missing... nginx!!! That freaked me out, but then I realized that nginx must be a dependency of python-certbot-nginx, and I confirmed that. So maybe this method would work after all?



I ran sudo apt-get upgrade on my test server and the output remained unchanged after using



sudo debfoster -q
sudo echo $(diff --new-line-format="" --unchanged-line-format="" /var/lib/debfoster/keepers ~/startkeepers) | tr ' ' 'n'


However, on my real server, the one I'm trying to configure this scripted duplication for, there are an additional two lines in it that I don't think should be there:



linux-headers-4.4.0-112-generic
linux-image-4.4.0-112-generic


I didn't manually install those... And don't want to install them on another server, unless whoever determined they were necessary does so again. Could it have been apt-update?



TLDR; What's a reliable way to keep track of a server-version agnostic list of manually installed packages, where manually means stuff the user knows about installing, not were installed by upgrades or however linux headers and kernel versions get installed? Anything that improves my process would be appreciated, bonus points for using apt tools instead of debfoster, considering its developers claim apt supports all of its features.










share|improve this question















As part of a larger backup-restore scheme, I'm trying to get a concise list of an ubuntu 16.04 server's installed packages. I want the list to be as short as possible and potentially be useful even five years later on a new LTS version of ubuntu.



Consider the following scenario:



Day 1: I install ubuntu 16.04 server on a machine.



Day 2: I install php-fpm



Day 3: I install nginx, php, and sendmail



Day 4: I install atanks. No, I don't know why I'm installing a graphical game on a headless server. The point is just to add more stuff which was manually installed to apt's database.



Day 5:
My server explodes in a fiery inferno. Maybe a tank explosion had something to do with it. In any case, I need to create a new server based on the backup.



In my backup script, I'd like to be able to generate the following line based on my apt-get activity over the past few days:



apt-get install atanks nginx php php-fpm sendmail


So how do we do that?



First, I tried some apt queries,



apt-mark showmanual


but they seemed to list hundreds of packages more than I had manually installed.



Second, I found debfoster:



Right after installing ubuntu, I'd run:



sudo apt-get update
sudo apt-get -y install debfoster
sudo debfoster -q
sudo cp /var/lib/debfoster/keepers ~/startkeepers


And normal server operations could continue. I or other users of the server might install any number of packages.



In my backup script, I'd have the following:



sudo debfoster -q
sudo echo $(diff --new-line-format="" --unchanged-line-format="" /var/lib/debfoster/keepers ~/startkeepers) > apt-get.list


And then I could restore on a new install with:



apt-get install -y $(cat apt-get.list)


Unfortunately, this method isn't working perfectly due to different packages either installing or not installing certain reccommends.



When after storing startkeepers, I run



sudo apt-get install -y nginx php-fpm python-certbot-nginx sendmail composer php-mbstring php-xml php-zip php-mysql
sudo debfoster -q
sudo echo $(diff --new-line-format="" --unchanged-line-format="" /var/lib/debfoster/keepers ~/startkeepers) | tr ' ' 'n'


This last line has the following output:



composer
php-fpm
php-mbstring
php-mysql
php-xml
php-zip
python-certbot-nginx
sendmail


This is missing... nginx!!! That freaked me out, but then I realized that nginx must be a dependency of python-certbot-nginx, and I confirmed that. So maybe this method would work after all?



I ran sudo apt-get upgrade on my test server and the output remained unchanged after using



sudo debfoster -q
sudo echo $(diff --new-line-format="" --unchanged-line-format="" /var/lib/debfoster/keepers ~/startkeepers) | tr ' ' 'n'


However, on my real server, the one I'm trying to configure this scripted duplication for, there are an additional two lines in it that I don't think should be there:



linux-headers-4.4.0-112-generic
linux-image-4.4.0-112-generic


I didn't manually install those... And don't want to install them on another server, unless whoever determined they were necessary does so again. Could it have been apt-update?



TLDR; What's a reliable way to keep track of a server-version agnostic list of manually installed packages, where manually means stuff the user knows about installing, not were installed by upgrades or however linux headers and kernel versions get installed? Anything that improves my process would be appreciated, bonus points for using apt tools instead of debfoster, considering its developers claim apt supports all of its features.







apt server bash package-management backup






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 27 at 5:56

























asked Feb 27 at 5:15









Menasheh

200113




200113











  • The reliable way is to write down the list of programs as you install them.
    – dsstorefile1
    Feb 27 at 6:29
















  • The reliable way is to write down the list of programs as you install them.
    – dsstorefile1
    Feb 27 at 6:29















The reliable way is to write down the list of programs as you install them.
– dsstorefile1
Feb 27 at 6:29




The reliable way is to write down the list of programs as you install them.
– dsstorefile1
Feb 27 at 6:29















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1010170%2fgenerate-the-shortest-possible-apt-get-install-command-to-duplicate-installation%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1010170%2fgenerate-the-shortest-possible-apt-get-install-command-to-duplicate-installation%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

pylint3 and pip3 broken

Missing snmpget and snmpwalk

How to enroll fingerprints to Ubuntu 17.10 with VFS491