You are not logged in.

#1 2009-01-19 20:02:16

ahronzombi
Member
From: /
Registered: 2007-05-06
Posts: 108
Website

backing up pacman DB for future corruptions

i just had to reinstall. does anyone have advise on howto backup my pacman db image for any future db corruptions?


Registered: 2007-05-05
Keep coming back to Arch because its hands down the most amazing distro God has given us.

Offline

#2 2009-01-19 20:54:14

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: backing up pacman DB for future corruptions

I use rsync.

alias backup="rsync -a --delete --verbose /var/lib/pacman/local/ /var/lib/local.back"

Offline

#3 2009-01-19 20:59:53

kjon
Member
From: Temuco, Chile
Registered: 2008-04-16
Posts: 398

Re: backing up pacman DB for future corruptions

tar -cjvf /path/to/mountpoint/pacman.db.bz2 /var/lib/pacman

that should do the trick.

However, If I were you, I would save the list of the explicit installed packages. The result would be 10 times smaller and simpler to apply if you wreck your system again.

in that case, first save the list:

pacman -Qqe | grep -v '$(pacman -Qqm)' > installed_packages.lst

and for recoverying your system, just do:

cat installed_packages.lst | xargs pacman -S --noconfirm

i hope it helps

Last edited by kjon (2009-01-19 21:05:51)


They say that if you play a Win cd backward you hear satanic messages. That's nothing! 'cause if you play it forwards, it installs windows.

Offline

#4 2009-01-19 21:09:01

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: backing up pacman DB for future corruptions

kjon wrote:

...

in that case, first save the list:

...

i was going to ask about this...

i backup /etc and /home regularly along with a

pacman -Q > paclog_[timestamp]

i'm hoping that if anything should happen i can restore my packages rather easily with a

packs=$(awk '{ print $1 }' paclog_*); pacman -S $packs

edit: three steps (cat grep awk) to one (awk) in the above smile

amazing how pacman would reorder all the packages by dependency and just reinstall anything already installed, but can it handle soooo many arguments?

Last edited by brisbin33 (2009-01-19 21:11:25)

Offline

#5 2009-01-19 21:18:04

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: backing up pacman DB for future corruptions

kjon's suggestion will only restore packages that are available in your repos, i.e. if you haven't installed any custom packages with "pacman -U". If that's the case then it will work (there's no need to save a list of all packages because non-explicitly installed packages will be pulled in as dependencies).

If not, you could use metapax (in the AUR or from my site) to create a system snapshot metapackage. By doing so, any package which cannot be found in a repo will be reconstructed from the installed files on your system.

Last edited by Xyne (2009-01-19 23:51:07)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#6 2009-01-19 21:29:07

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: backing up pacman DB for future corruptions

ah, yes... thank you Xyne for clarifying the explicitly installed only approach vs my overkill approach... i'll be updating my backup and restore scripts...

good luck ahronzombie, it looks like you've got a few options

Offline

#7 2009-01-19 22:12:35

kjon
Member
From: Temuco, Chile
Registered: 2008-04-16
Posts: 398

Re: backing up pacman DB for future corruptions

thanks xyne for the clarification. At least, you gave enough time to had a very pleasant cup of tea big_smile My fingers are sort of tired today. To much keyboard work; you saved me from an additional explanation.

Last edited by kjon (2009-01-19 22:15:39)


They say that if you play a Win cd backward you hear satanic messages. That's nothing! 'cause if you play it forwards, it installs windows.

Offline

#8 2009-01-19 22:20:10

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: backing up pacman DB for future corruptions

Actually, if you want to be safe, I would do both.
I would either use rsync or tar or whatever to backup /var/lib/pacman/local (don't backup /sync, it does not make sense, and /sync is actually twice as big as /local here), which allows a quick and safe restore of all your installed packages, whether they came from a repo or not.
I would also keep the list of installed packages somewhere, in case the backups didn't work or are corrupted or whatever. That's also the only thing you would need to do a complete reinstall.


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#9 2009-01-20 14:48:23

ahronzombi
Member
From: /
Registered: 2007-05-06
Posts: 108
Website

Re: backing up pacman DB for future corruptions

what would be the best way of setting this up automaticly, cron? just curious, i havent created allot of cron jobs in my day. we should totally think this out and make a guide, since pacman has no recovery function.


Registered: 2007-05-05
Keep coming back to Arch because its hands down the most amazing distro God has given us.

Offline

#10 2009-01-20 14:56:08

ahronzombi
Member
From: /
Registered: 2007-05-06
Posts: 108
Website

Re: backing up pacman DB for future corruptions

right now im using backintime to create snapshots of /var/lib/pacman and im backing them up to my /home partition, thats where i do allot of my config backups


Registered: 2007-05-05
Keep coming back to Arch because its hands down the most amazing distro God has given us.

Offline

#11 2009-01-20 15:21:26

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: backing up pacman DB for future corruptions

i use fcron to run a backup script as root once weekly.  this compresses /etc and /home and creates kjon's pacman listing; all to an external usb.

i have a restore script written that will pacman -S from the listing, then extract /etc and /home while preserving the permissions.

i see no reason why i couldn't have my system back both quickly and easily after a crash.  who needs apple's time machine, huh?

Offline

#12 2009-01-20 15:27:31

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: backing up pacman DB for future corruptions

What do you think time machine is based off of?


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#13 2009-01-20 15:33:08

wain
Member
From: France
Registered: 2005-05-01
Posts: 289
Website

Re: backing up pacman DB for future corruptions

I use yaourt --backup to save the db and "yaourt --backup pacman-xxx.tar.bz2" to restore it smile

Offline

#14 2009-01-20 16:19:35

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: backing up pacman DB for future corruptions

[offtopic]

rson451 wrote:

What do you think time machine is based off of?

from what i can gather, the first backup is a full copy.  each subsequent backup contains hardlinks to any unchanged files and a full copy of anything that's changed.

a far cry from cron and tar i'd say wink [/offtopic]

Offline

#15 2009-01-20 17:22:37

u_no_hu
Member
Registered: 2008-06-15
Posts: 453

Re: backing up pacman DB for future corruptions

brisbin33 wrote:

[offtopic]

rson451 wrote:

What do you think time machine is based off of?

from what i can gather, the first backup is a full copy.  each subsequent backup contains hardlinks to any unchanged files and a full copy of anything that's changed.

a far cry from cron and tar i'd say wink [/offtopic]

A far cry from rsync incremental backups?


Don't be a HELP VAMPIRE. Please search before you ask.

Subscribe to The Arch Daily News.

Offline

#16 2009-01-20 17:42:53

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: backing up pacman DB for future corruptions

u_no_hu wrote:

A far cry from rsync incremental backups?

That's what I was getting at.  Rsync is to Time Machine what ls is to PCmanFM. (Over-exaggeration, I know, I know)  Who needs a stinkin' guitastic wrapper for something that's been around for ages. big_smile


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#17 2009-01-20 18:22:27

ahronzombi
Member
From: /
Registered: 2007-05-06
Posts: 108
Website

Re: backing up pacman DB for future corruptions

wain wrote:

I use yaourt --backup to save the db and "yaourt --backup pacman-xxx.tar.bz2" to restore it smile

yaourt is the shit. ive always loved it and had no idea it would do my backups that rocks. i think ill use that in cron as root if it will work


Registered: 2007-05-05
Keep coming back to Arch because its hands down the most amazing distro God has given us.

Offline

#18 2009-01-20 18:33:42

ahronzombi
Member
From: /
Registered: 2007-05-06
Posts: 108
Website

Re: backing up pacman DB for future corruptions

so im guessing to create a fcron entry to do this i would start by doing : sudo fcrontab -u ahron -e "

but then once im in the editor wat would be the syntax to setup a daily job of yaourt --backup? all the manuals im reading are not so simple, once i get the hang of it it should be easier.


Registered: 2007-05-05
Keep coming back to Arch because its hands down the most amazing distro God has given us.

Offline

#19 2009-01-20 18:38:13

ahronzombi
Member
From: /
Registered: 2007-05-06
Posts: 108
Website

Re: backing up pacman DB for future corruptions

ok i ran that command and put this in the crontab 45 18 * * * /usr/bin/yaourt --backup

that will run it at 6:45 every day right?


Registered: 2007-05-05
Keep coming back to Arch because its hands down the most amazing distro God has given us.

Offline

#20 2009-01-20 18:48:52

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: backing up pacman DB for future corruptions

ahronzombi wrote:

ok i ran that command and put this in the crontab 45 18 * * * /usr/bin/yaourt --backup

that will run it at 6:45 every day right?

that'll do it! i'm not familiar with yaourt but if the --backup command requires root privileges then just run

sudo fcrontab -u root -e

and put that line in that [f]crontab instead

Offline

#21 2009-01-24 19:04:13

ahronzombi
Member
From: /
Registered: 2007-05-06
Posts: 108
Website

Re: backing up pacman DB for future corruptions

Hey guys, this is stable so far, yaourt creates a backup every night at 6:45 , then i also run pacman -Qqe | grep -v '$(pacman -Qqm)' > /home/ahron/installed_packages.lst directly after that.  My question is the yaourt backups like pacman-2009-01-24_18h45.tar.bz2 will add up. im pretty sure i could setup away to delete backups over a week old automatically, can anyone assist me with that. I promise i very much love all this help and i am totally learning even though ive been using linux for 10 years or so.


Registered: 2007-05-05
Keep coming back to Arch because its hands down the most amazing distro God has given us.

Offline

#22 2009-01-24 20:11:18

ahronzombi
Member
From: /
Registered: 2007-05-06
Posts: 108
Website

Re: backing up pacman DB for future corruptions

i asked my brother in law, he said it would be best to add a fcron entry for
find /home/ahron/ -type f -name 'pacman-*bz2' -mtime +7 -delete


Registered: 2007-05-05
Keep coming back to Arch because its hands down the most amazing distro God has given us.

Offline

#23 2009-01-24 20:20:32

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: backing up pacman DB for future corruptions

ahronzombi wrote:

i asked my brother in law, he said it would be best to add a fcron entry for
find /home/ahron/ -type f -name 'pacman-*bz2' -mtime +7 -delete

That looks fine. But just for safety and also organizational purpose, I would put all your backups in a directory, like /home/ahron/backups


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#24 2009-01-25 03:45:28

ahronzombi
Member
From: /
Registered: 2007-05-06
Posts: 108
Website

Re: backing up pacman DB for future corruptions

shining wrote:
ahronzombi wrote:

i asked my brother in law, he said it would be best to add a fcron entry for
find /home/ahron/ -type f -name 'pacman-*bz2' -mtime +7 -delete

That looks fine. But just for safety and also organizational purpose, I would put all your backups in a directory, like /home/ahron/backups

good tip. but im a messy guy


Registered: 2007-05-05
Keep coming back to Arch because its hands down the most amazing distro God has given us.

Offline

#25 2009-04-02 00:54:26

ahronzombi
Member
From: /
Registered: 2007-05-06
Posts: 108
Website

Re: backing up pacman DB for future corruptions

Ok since they are dropping i686 support i went to x64 . but i was stupid and didnt relize crontabs were in var not /etc . now i lost everything i created. i feel so dumb. i had a good backup script that made a dated tar.gz  of my etc directory . does anyone who already has something like this setup on their system have any tips for me to recreate what i had before?


Registered: 2007-05-05
Keep coming back to Arch because its hands down the most amazing distro God has given us.

Offline

Board footer

Powered by FluxBB