RHEL: Get yum "snapshot" and reuse

jibbajabbajibbajabba Member Posts: 4,317 ■■■■■■■■□□
Is there a way to get a list of packages installed via yum, piped somehow into a list which can then be used on a different server to install the exact packages ?
My own knowledge base made public: http://open902.com :p

Comments

  • log32log32 Users Awaiting Email Confirmation Posts: 217
    you can certainly do that with shell scripting I guess.
    List all installed packages with:
    [COLOR=#333333]yum list installed[/COLOR]
    
    you will get something similar to this:

    zlib-devel.x86_64 1.2.3-3 installed
    zsh.x86_64 4.2.6-5.el5 installed

    with that output, you can simply take the first field with:
    yum list installed | awk {'print $1'}
    
    redirect it to a text file and run a for loop on it.
    good luck
  • jibbajabbajibbajabba Member Posts: 4,317 ■■■■■■■■□□
    log32 wrote: »
    yum list installed | awk {'print $1'}
    

    Thanks, that was the missing pipe-bit I was looking for.

    A lot of people suggest yum-debug-**** and yum-debug-restore but for some reason yum-debug-restore is missing from yum-utils
    yum list installed | awk {'print $1'} > installed.txt
    

    then
    yum -y install $(cat installed.txt)
    

    worked like a charm - thanks for the hint !!
    My own knowledge base made public: http://open902.com :p
  • log32log32 Users Awaiting Email Confirmation Posts: 217
    nice to know it worked as expected icon_smile.gif
  • jibbajabbajibbajabba Member Posts: 4,317 ■■■■■■■■□□
    You just have to be very careful with this. I blindly did that on a system now forgetting its on a different build ... (5.7 as opposed to 5.9) ..

    Both really need to be on the same patch level - which might make it a little bit more difficult.
    My own knowledge base made public: http://open902.com :p
  • hiddenknight821hiddenknight821 Member Posts: 1,209 ■■■■■■□□□□
    I was surprised the awk syntax Log32 used actually worked. I didn't believe it until I tested it. I prefer the single quote outside the bracelets, not within. This is what I see in most examples on the Net.

    jibbajabba Can't you just update both systems to the latest patches?
Sign In or Register to comment.