Suse:从 /var/adm/backup/rpmdb/Packages-20160323 .gz 恢复软件包列表

Suse:从 /var/adm/backup/rpmdb/Packages-20160323 .gz 恢复软件包列表

在 Suse-Linux 上,您有 rpmdb 的 gzip 备份: https://www.novell.com/documentation/suse91/suselinux-adminguide/html/ch02s03.html#sec:rpm.anfragen

但是我如何从这个文件中获取所有已安装包的列表?

如果我解压缩它,它是这种文件类型:

file Packages-20160323 
Packages-20160323: Berkeley DB (Hash, version 8, native byte-order)

我试过了rpm --dbpath但是这个选项想要一个目录而不是一个 berkley-db-file....

答案1

我找到了这个解决方案:

#!/bin/bash
# get-package-list-from-backup.sh
set -e
set -x
cd /var/adm/backup/rpmdb
for gzipfile in *.gz; do (
 base=${gzipfile/.gz/}
 dir=/var/tmp/rpmdb-restore-$base
 mkdir $dir
 cp $gzipfile $dir
 cd $dir
 gunzip $gzipfile; mv $base Packages
 rpm --dbpath $dir -qa | sort > qa.list )
done

现在我可以看到区别了:

vimdiff /var/tmp/rpmdb-restore-Packages-20150625/qa.list /var/tmp/rpmdb-restore-Packages-20160311/qa.list

相关内容