Is it possible to backup & restore your portage tree?

A place to ask all newbie questions and not get flamed, though you will get beaten down if you post a newbieish question outside of these walls.
Post Reply
Krazy
Adept
Posts: 54
Joined: Wed Sep 10, 2003 8:41 pm
Location: Auckland, New Zealand

Is it possible to backup & restore your portage tree?

Post by Krazy »

Hi,

My Home 4.0 install needs a cleanup. I think emerging gdm & xorg-x11 [to latest versions] have left rubbish lying around. :(
I'm thinking of reinstalling from CD, but am wondering if it is possible to backup the portage tree beforehand, and restore to a new install.

Why? Well the initial 'emerge --sync' took so long, and downloaded quite a number of files. I'd like not to have to repeat that if I can.
Note: The current version of portage I'm using is not the default stock version. I've upgraded from that.

There's probably a cache somewhere of installed files that needs to be nuked as part of a tree restore.
Is this feasible? Any pointers on the bits I do/don't need. I already know that package source I emerged can be found in /usr/portage/distfiles

Am I asking for trouble? Thoughts?
v1.1 xbox, stock HD, soft-modded [uxe+ dualboot: UnleashX/GentooX], with Pro2.0
v1.4 xbox, stock HD, Xecuter3 (X3 3294), running headless with Home 6.1
Krazy
Adept
Posts: 54
Joined: Wed Sep 10, 2003 8:41 pm
Location: Auckland, New Zealand

Post by Krazy »

I said:
I'm thinking of reinstalling from CD, but am wondering if it is possible to backup the portage tree beforehand, and restore to a new install.
The answer is a resounding yes!

Why do this? Well by the time I was ready to reinstall from CD, my portage tree (ie /usr/portage) was over 500Mb in size.
Check yours, you may be surprised!

Code: Select all

cd /usr/portage; du -k .
The last line printed "XYZ .", shows the number of 1K blocks used (ie XYZ blocks)
Compare this with a fresh Home 4.0 install, where /usr/portage is empty (0Mb) !!!

While the size of the source tarballs in /usr/portage/distfiles was significant, but I decided to help myself further by making binary packages of things I installed to help speedup the install & restore process, so these added to my tree size too.

How do you make binary packages? Assuming you've already installed the package from source using emerge, then all you need to do is use 'quickpkg <pkgname>' (no quotes). This ends up storing a binary package file <pkgname>.tbz2 [ie uses bzip2] in /usr/portage/packages/All
Note: you'll only get a package for the named package, not its dependencies (of which there may be none, or a lot)

What about portage's knowledge of installed packages, you might ask?
Don't worry about that as its not stored in /usr/portage, but elsewhere.
Therefore restoring you archive to a new box won't cause any issues on that front.

So how do you take advantage of those binary packages?
Just backup the whole portage tree, they'll go along for the ride. Note: this may take a while....

Code: Select all

cd /tmp; tar cvjf portage.tar.bz2 /usr/portage
Now backup "portage.tar.bz2" to your pc/mac etc

Next re-intall Gentoox, then restore and extract your archive

Once you've restored your portage tree on your new install, just emerge packages you want with option "-k", and emerge will take any binary packages it finds on the local filesystem (assuming they're required), saving you the download, and compile time. Great! :wink:

If no binary package is found, then things proceed normally (download, compile, merge, update config etc)
v1.1 xbox, stock HD, soft-modded [uxe+ dualboot: UnleashX/GentooX], with Pro2.0
v1.4 xbox, stock HD, Xecuter3 (X3 3294), running headless with Home 6.1
Post Reply