How to backup installed packets ?

Hello all,

As I can't seem to repair the sound problems I'm having I'm pretty much forced to reinstall everything from the ground up. As such I'm also looking at how to backup packages I'm going to (re)install. The problem with those is ofcourse their dependancies.

After a lot of googeling I stumbled over a way to get an installed packets dependancies:

apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances | grep "^\w" | sort -u

The problem is that those are just the basic package names, while I need the filenames as present in the "/var/cache/apt/archives/" folder. Some further searching gave me a way to get a filename from the package name:

apt-cache show | grep Filename

The problem with this one is that although I get a filename, I sometimes can't find it back in the above mentioned folder

For instance, "apt-cache show blues | grep Filename" returns two filenames, neither of which are in the cache: bluez_5.50-1+rpt1_armhf.deb and bluez_5.50-1+b12_armhf.deb. However, bluez-obexd_5.50-1+rpt1_armhf.deb is (which is mentioned as a dependancy for "blueman").

Does anyone have any information to

1) why "apt-cache" returns filenames that do not exist in the cache (lots and /lots/ of them) 2) how I can get "apt-cache" (or some other program) to return the names of actually cached files

Regards, Rudy Wieser

P.s. If there is onother way to download packages /and its dependancies/ for offline, later install I'd like to hear it (I've seen "apt-offline" being mentioned, but got some "combersome" remarks).

Reply to
R.Wieser
Loading thread data ...

To get a list packages installed on your system

dpkg --get-selections > /some_file

You'll need to save the file somewhere for use later

On a new install, you then do

dpkg --set-selections < /some_file

You don't need to worry about the dependencies. If a package has dependancies they will be installed with the package.

Reply to
Jim Jackson

Jim,

That one lists /all/ packages (al lot), including those that are part of installation of the OS, which do not need to be backupped. Its the ones I've added (installed by hand) that need to be.

:-) The idea is that I can install everything (the .deb files) /offline/ - without having to depend on the internet.

Regards, Rudy Wieser

Reply to
R.Wieser

Doesn't matter. If the package is already installed it will be skipped - things don't installed twice - unless there is a more recent version of the package.

You really do like making things difficult don't you!

Reply to
Jim Jackson

Jim,

The idea is that I can use those backups when I need to /re-install the OS from from scratch/ (like when the sd card dies). There won't be any already installed packages there.

Whut ? My wish not to have to depend on "tha intarwebz" is considered "making things difficult" ? Really ?

Personally I do not like to depend on resources that are beyond my control. Like those packages that could still be available when I need them again, but most likely will have changed in the mean time (new versions and all that), and as such could have become incompatible with what I find most important, /my/ stuff. Its as simple as that.

Regards, Rudy Wieser

P.s. Yes, I could just save the cache with all the .deb files and bulk re-install them (can I do that?), but as long as I'm looking at it anyway I would like to be able to do it in a less coarse way (giving me the possibility, when re-installing, to leave out packages I am no longer using).

Reply to
R.Wieser

OK, surely an old school system backup meets all your requirements. Install everything you want and then just copy the entire sd card to a tar file. When reinstalling you can just restore this tar file.

Alternative Internet dependent modern solutions are:

Automate installation using provisioning software such as Chef or Ansible. You write a script for exactly how you want to set the machine up and the provisioning software will install everything you need, so no need for a system backup. I've never done this but you can look it up.

Or, I take a third path where I run Docker containers and install very little on my base Linux distribution. So reinstalling is trivial.

Reply to
Pancho

Just backup the whole system. It?s easier and it?s more accurate (no special steps needed to recreated the prior configuration).

--
https://www.greenend.org.uk/rjk/
Reply to
Richard Kettlewell

On Tue, 24 Dec 2019 10:47:18 +0100, "R.Wieser" declaimed the following:

Better to maintain pre-configured spare SD cards...

Maybe plug in a USBSD-card reader and use

Accessories/SD Copier

{I've not tried that -- I just keep a shell script of apt commands on my Windows box, since it I prefer to rebuild full Raspbian /with updates/ from the NOOBS full download and an on-line connection. Relying upon copies of some downloaded .DEB files puts one at risk of having packages missing security updates, et al -- which requires an on-line connection just to do apt update/apt upgrade to correct them}

--
	Wulfraed                 Dennis Lee Bieber         AF6VN 
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
Reply to
Dennis Lee Bieber

Hello Rudy and others,

Mon. 23 Dec 2019, 21:13:53, R. Wieser wrote to All:

RW> The idea is that I can install everything (the .deb files) /offline/ - RW> without having to depend on the internet.

The most simpel and easiest way is to make full BackUps; i.e. GrandFather, Father ans Sun principle. No internet connection needed for this. Use two (micro-)SDcard reader/writers and (micro-)SDcard form the same make, and capacity, but if possible different makes of (micro-)SDcard reader/writers. The first one with the source card inserted as first. The second one with the destination card inserted after that. Then unmount all (micro-)SDcard readers/writers from the taksbar, or with the "unmount" command, but leave the readers/writers in de USB-ports of the machine! That is necessarry to slo close all files on both cards. That way the (original) source (micro-)SDcard/disk is mostly /dev/sda and the destination (backup) (micro-)SDcard/disk is /dev/sdb, Be very careful, as inserting the source and destination in the wrong order, they get other device names, and can confuse you very much. Than you can overwrite your original with the contents of a new emty or old card/disk, so that can be very dangerous. I use different make of card readers/writers so I can recognise wich one is sda and wich is sdb. After this do, when you are very sure about the right device names:

pi@raspberrypi:~ $ sudo dd if=/dev/sda of=/dev/sdb bs=4M pi@raspberrypi:~ $ sudo sync

After this remove both cardreader/writers and insert the destination version, to see if if the backup worked ok and is readable! But note: you can not mount two identical (micro-)SDcards anymore since Raspbian Stretch! That has to do with the same UID's. So I use the 32 GB card for booting to look at the 16 GB backup, and also the other way round, look at a 32 GB backup from a 16 GB booted card.

Second tip: Create a text file called "owner" in both the Fat32 partition and the EXT4 partion with your name, adres, e-mail and phone number in it, and the first creation date of that Linux imageand added with the linux version info.

Copying 16 GB takes 30 minutes and copying 32 GB takes 60 minutes on a Pi 3B. I have not tested this on the 4GB Pi 4B at the 2 USB3A ports. It should be remarkably faster. But I donot have USB3A cardreader/writers.

Do NOT use the inbuild software SDcard Copier, as it is NOT reliable, and backing up from the interne mmcblk0 is not done either, because of allways open files, the backup made is than not 100 % identical! But for the very first backup you can do that, so you can make backups with the 2 cardreaders/writers all the next sessions, including overwritin that first wrong backup witch a new fresh one made with dd instead of the SDcard Copier. So always use a good working Raspbian Linux card for making backups of other cards.

When a card got corrupted, i.e. Linux does not start anymore from it, first try to get as much private data from it as you can in another machine, i.e. to an USB stick or another microSDcard by using the cardwriter. Mostly the directory structure is readable for the biggest part, it only does not boot anymore. After this, you can restore the latest backup on that corrupted card in the same way as making backups above. And then restore the earlier saved private files back to their original locations on the fresh card. When done, make immediately a new backup on another card, not the one you used to create this one, if you understand me. Then you can going working as usual.

I only change Linux versions once a year with a completely ne install, and I made a textfile for personalisation of the new version with my previous experiences, to make new installations faster the way I want my setups. And indeed you can use your .deb files on the new version too. The rest of the year doing: sudo apt-get update sudo apt-get upgrade will be enough I think, and normally only necessarry when installing new packages and tools etc. Good luck.

Henri.

Reply to
Henri Derksen

Dennis,

In my case that would most likely not be a problem, as I tend to keep my Pi offline.

But ... Do you know how to have the Pi check if certain /security/ updates are of interrest (to my current installation) ? And I do mean security updates only.

Regards, Rudy Wieser

Reply to
R.Wieser

On Sun, 29 Dec 2019 11:07:42 +0100, "R.Wieser" declaimed the following:

Unfortunately, Raspberry-Pi foundation doesn't separate them -- all packages are under a single repository

pi@rpi3bplus-1:~$ cat /etc/apt/sources.list deb

formatting link
buster main contrib non-free rpi

In contrast, purer Debian actually has some separation between core, updates, and security, and commenting out the first two would likely leave only security updates to be found by apt update.

debian@beaglebone:~$ cat /etc/apt/sources.list deb

formatting link
stretch main contrib non-free

deb

formatting link
stretch-updates main contrib non-free

deb

formatting link
stretch/updates main contrib non-free

Obviously not of use when the foundation builds its own binaries (due to variations in hardware, the foundation builds with a different floating point instruction set from what Debian itself uses).

--
	Wulfraed                 Dennis Lee Bieber         AF6VN 
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
Reply to
Dennis Lee Bieber

If it's not online why do you need security updates? Where's the attack vector for an air-gapped system?

Reply to
mm0fmf

Dennis,

Bummer.

Regards, Rudy Wieser

Reply to
R.Wieser

mm0fmf,

For the times I need to download packages ?

Besides, better ask now than to start with it when I need to access the internet yesterday.

USB devices (thumbdrives, keyboards, etc) ? NOOBS or other ways to install an OS ? Packages ? Bluetooth ? Wifi ? Poisonned resource files (images, music, video, spreadsheets) ? Booby-trapped source-code ?

Air-gapping isn't the ends-all defence against intrusions you know. :-)

Regards, Rudy Wieser

Reply to
R.Wieser

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.