You are not logged in.

#1 2015-10-04 18:28:30

Ocypheum
Member
Registered: 2015-09-26
Posts: 58

[Solved] Why backup /var or pacman database?

I've been reading about backup recommendations and I'm confused about a couple of things...

Create backups of important data at regular intervals. Directories to consider are /etc, /home and /var, and, for server installations, also /srv.

Why would I want to backup /var? As I understand it, /var contains only disposal data, such as cached files, log files and temp files. I also understand this is where the local pacman database resides, which brings me to my next question...

Why would I want to backup the local pacman database? Especially if I keep a list of installed packages, this step seems redundant. In the case that it is necessary to backup the database, would it still be a good idea to keep a list of installed packages?

Last edited by Ocypheum (2015-10-16 15:24:33)

Offline

#2 2015-10-04 18:48:35

frank604
Member
From: BC, Canada
Registered: 2011-04-20
Posts: 1,212

Re: [Solved] Why backup /var or pacman database?

All of that is situational to the user and their own needs.  Some people go extensively to make backups of everything while some just backup dotfiles.  It is entirely up to you.

As to local pacman database, it is handy to have a backup of installed packages in case an upgrade borks you.  You then have a binary package to downgrade to.  Otherwise, you could use the arch rollback machine, assuming you have internet access.  Speaking of internet, what I do is keep a separate backup of my wl driver, which I'm fortunate to do because the latest driver is buggy. 

You are the captain of your computer.  If you feel it is unnecessary then don't.  If you think it is nice to have considering the past X & Y events that have wasted your time then consider to do A & B.

Offline

#3 2015-10-05 05:08:55

hydracone
Member
Registered: 2015-06-25
Posts: 24

Re: [Solved] Why backup /var or pacman database?

You probably don't need to backup the pacman database, but you can keep a copy of your package cache at /var/cache/pacman/pkg. That way, if you want to install packages on any other system (or do a fresh install on the same system) without downloading them all over again, you can just copy your package cache onto your new system.

Offline

#4 2015-10-05 09:49:01

TheChickenMan
Member
From: United States
Registered: 2015-07-25
Posts: 354

Re: [Solved] Why backup /var or pacman database?

frank604 wrote:

You are the captain of your computer.

Best thing about Arch. That feeling of command when you decided what your computer should do and it does that.
Running other operating systems always made me feel like that loley redshirt with no first name, one day from retirement.

I don't really like to bother backing up my / partition so I keep most of my "important" things there that I might want to save such as the pacman cache and web server content simlinked from a different drive which is backed up. Like frank said, everyone's computer and needs are different. Everyone makes their own decisions about what is best for their own situation.

Last edited by TheChickenMan (2015-10-05 09:54:06)


If quantum mechanics hasn't profoundly shocked you, you haven't understood it yet.
Niels Bohr

Offline

#5 2015-10-05 10:17:01

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,901
Website

Re: [Solved] Why backup /var or pacman database?

if I keep a list of installed packages, this step seems redundant.

Pacman's database contains a lot more than just a list of packages, so backing it up is not as redundant as you might think. It contains versions, file lists, checksums, dependency information, package install reasons, and some other metadata; in short, all the information that pacman needs to check the status of your installed packages and help you restore the system to a usable state.

If you lose pacman's database, it's a lot harder to restore it to a consistent state than it is to restore the rest of your filesystem to a usable state using pacman's database.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Online

#6 2015-10-10 23:41:18

Ocypheum
Member
Registered: 2015-09-26
Posts: 58

Re: [Solved] Why backup /var or pacman database?

frank604 wrote:

As to local pacman database, it is handy to have a backup of installed packages in case an upgrade borks you.  You then have a binary package to downgrade to.

So the pacman database contains all the binary packages I've installed? I thought that was the package cache. If I backup /var/cache/pacman/pkg, should I still backup /var/lib/pacman/local? I assume the cache is smaller. Is it worth the additional time/space to backup the database instead of or in addition to the cache?

Speaking of internet, what I do is keep a separate backup of my wl driver, which I'm fortunate to do because the latest driver is buggy.

 

Glad you reminded me. If my driver is from AUR, would it be included in my pacman database or my package cache?

You are the captain of your computer.  If you feel it is unnecessary then don't.

I understand completely. This is the primary reason I use Linux every day. I just want to know why other people recommend what they recommend and not blindly follow what the wiki says. The wiki is great, but in this case it's lacking a good explanation of why to do these things.

Offline

#7 2015-10-11 00:06:15

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,901
Website

Re: [Solved] Why backup /var or pacman database?

Pacman's cache is a collection of package archives your system has downloaded. Usually there is no need to back these up as the most recent version of these archives is available on Your Friendly Neighbourhood Mirror. Generally speaking, anything in /var/cache should be considered disposable. It is still useful to have these archives available in case of an update causing problems, or minor filesystem corruption, so you can reinstall the package without having to redownload it.

Your pacman database, however, is comprised of a lot of textfiles and mtree files relating to the packages you have installed on a particular system. It is queried whenever you start a pacman transaction (e.g. installing or removing a package), and when you run a pacman query (-Q). The pacman database also contains information from Your Friendly Neighbourhood Mirror, which is used when querying the sync databases (-Ss/-Si/-Sl/etc.)

https://wiki.archlinux.org/index.php/Cr … s#Overview and https://wiki.archlinux.org/index.php/Pa … _structure are helpful links.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Online

#8 2015-10-11 00:17:12

HappyClown
Member
Registered: 2015-08-15
Posts: 161

Re: [Solved] Why backup /var or pacman database?

It's in case of something bad happening, like your computer freaking out after an update. If you back up the cache, you can revert back to an older version of that program until the issue is fixed.

Offline

#9 2015-10-11 05:13:44

Ocypheum
Member
Registered: 2015-09-26
Posts: 58

Re: [Solved] Why backup /var or pacman database?

I think I'll backup the database then and leave the cache. Perhaps I will learn my lesson later, as is generally the case smile

In addition, after reviewing all the changed package files using this helpful script, I've decided to backup the following as well:

/etc/fstab
/etc/group
/etc/gshadow
/etc/hosts
/etc/locale.gen
/etc/passwd
/etc/pacman.d/mirrorlist
/etc/resolv.conf
/etc/shadow
/etc/sudoers

These files were included in the output but I'm not sure if I need to back them up or if they are generated:

/usr/lib/modules/4.2.2-1-ARCH/modules.alias
/usr/lib/modules/4.2.2-1-ARCH/modules.alias.bin
/usr/lib/modules/4.2.2-1-ARCH/modules.dep
/usr/lib/modules/4.2.2-1-ARCH/modules.dep.bin

Also, using this script to find all the files that don't belong to any package, I've identified the following for backup:

/etc/hostname
/etc/locale.conf
/etc/modprobe.d/pcspkr.conf (disables PC speaker)
/etc/netctl/wlp2s0-OpenWrt (wifi profile)
/etc/systemd/system/getty@.service.d/noclear.conf (prevents console clearing on startup)
/etc/systemd/system/getty@.service.d/numlock.conf (enables numlock on startup)
/etc/systemd/system/getty.target.wants/getty@tty1.service (symlink to /usr/lib/systemd/system/getty@.service)
/etc/systemd/system/multi-user.target.wants/netctl@wlp2s0\x2dOpenWrt.service (symlink to /etc/systemd/system/netctl@wlp2s0\x2dOpenWrt.service)
/etc/systemd/system/multi-user.target.wants/remote-fs.target (symlink to /usr/lib/systemd/system/remote-fs.target)
/etc/systemd/system/netctl@wlp2s0\x2dOpenWrt.service (wifi service definition)
/etc/vconsole.conf

I'm not sure if I need these:

/etc/.updated
/etc/adjtime
/etc/dhcpcd.duid
/etc/dhcpcd.secret
/etc/machine-id
/etc/os-release
/usr/share/info/dir

I think these directories only contain certificates. Does anyone back these up?

/etc/ca-certificates/extracted/
/etc/pacman.d/gnupg/
/etc/ssl/certs/

I'm pretty sure I can safely ignore old kernel modules in /usr/lib/modules/4.2.1-1-ARCH/ but I'm not sure about these binaries:

/etc/ld.so.cache
/etc/localtime
/etc/udev/hwdb.bin
/usr/lib/libdialog.so.12.0.0
/usr/lib/locale/locale-archive

I know this is a very long post but any feedback is greatly appreciated.

Edit: I just had a panic moment when I realized my wireless driver is not in the pacman database or the cache, then I found the tarball in my home directory. Think I'll backup the cache afterall, and probably the entire /etc/ directory. (Obviously /home/ as well.)

Last edited by Ocypheum (2015-10-11 05:42:08)

Offline

#10 2015-10-11 19:54:50

nstgc
Member
Registered: 2014-03-17
Posts: 393

Re: [Solved] Why backup /var or pacman database?

WorMzy wrote:

if I keep a list of installed packages, this step seems redundant.

Pacman's database contains a lot more than just a list of packages, so backing it up is not as redundant as you might think. It contains versions, file lists, checksums, dependency information, package install reasons, and some other metadata; in short, all the information that pacman needs to check the status of your installed packages and help you restore the system to a usable state.

If you lose pacman's database, it's a lot harder to restore it to a consistent state than it is to restore the rest of your filesystem to a usable state using pacman's database.

There is, however no reason to keep several version of the database though, correct? Yesterday's, last week's, and last month's should be sufficient correct?

Offline

#11 2015-10-11 20:23:30

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,901
Website

Re: [Solved] Why backup /var or pacman database?

As soon as you run a pacman transaction (install something/remove something/update/change the install reason of a package), your backed up databases are OOD.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Online

#12 2015-10-12 07:15:03

Awebb
Member
Registered: 2010-05-06
Posts: 6,309

Re: [Solved] Why backup /var or pacman database?

Your initial question was: "Why is it recommended to backup /var?"

Your question can be answered with another question: "Why is /var not deleted during a shutdown, but /tmp is, although both are somewhat of a volatile nature?"

Last time I was an admin in an actual company, I even backed up /tmp on some systems, because I couldn't be sure there weren't any important things going on there, considering the 1500+ days uptime some of the boxes had.

Offline

Board footer

Powered by FluxBB