Return to Level1Techs.com

Backing up a Proxmox LXC Container

#1

I’m tasked with working a bit with a Proxmox server and am not very well versed with that.

I’m trying to make a full Backup of an existing Debian in an LXC Container. Goal is, to be able to fully roll back the machine if changes fail. It’s a one time operation, nothing to automate or such.

I’ve rsync’d the root to an external drive, but am unsure if this would restore fine. I’m more experienced with docker and not so much in LXC.

Do those of you that mo Proxmox better have any resources that i can get into to explain the Backup thing a bit?

0 Likes

#2

Not sure if this applies to Proxmox specifically, but I use “lxc export” on LXD to generate a tarball.

0 Likes

#3

I’ve never worked with containers but… Its a file right? Can’t you just DD it to a new container?

0 Likes

#4

No, they’re entire chrooted filesystems.

0 Likes

#5

Well thats even easier to DD then.

(although if LXD has a command for it, do that)

0 Likes

#6

Yeah, that’s my Problem. I’m not sure. With docker i now what is where. Not so much with LXC. And even less so with Proxmox. Like, how do i browse a proxmox storage?

0 Likes

#7

I wouldn’t use dd as it isn’t a block device, but you can backup the entire filesystem path if you prefer to do that.

0 Likes

#8

Would i do that from within the container, or from the Proxmox Server (Host)?

0 Likes

#9

You would run lxc export from the host, not inside the container. You can’t back up the entire container from inside itself. I’m sure there’s a “proxmox way” to do it too.

2 Likes

#10

Ok, I’m leaving work now, so i’ll look at it tomorrow. But i should be able to ssh into the Proxmox Host and work from there.
So far i’ve only seen the webfrontend. I hate webfrontends!

0 Likes

#11

Yes, I just use a cron to lxc export all my containers to tarballs then rclone to back them up to an encrypted google drive. Works great.

0 Likes

#12

I was reading and had a feeling of that.

Theres a console you can use.

Somewhere.

0 Likes

#13

You can open a shell from the webgui

1 Like

#14

I should probably play with it tbh I’ve been curious.

0 Likes

#15

The backups can eat up space if you don’t thin them out regularly though:

221G of container tarballs
[email protected]:~$ ls -lh /share/backups/raid-2019-07-09/lxc-backups/
total 221G
 -rwxrw-r-- 48 clifford clifford 1.1G Sep  2  2018 apache-server-090218.tar.gz
-rw-r--r-- 48 clifford clifford 807M Nov 30  2018 aws-openvpn-container-2018.11.30.tar.gz
-rw-r--r-- 48 clifford clifford 355M Nov 30  2018 bind9-container-2018.11.30.tar.gz
-rwxrw-r-- 16 clifford clifford 1.9G Jun 24 02:16 cgi-server-2019-06-24.tar.gz
-rwxrw-r--  9 clifford clifford 1.9G Jul  1 02:22 cgi-server-2019-07-01.tar.gz
-rwxrw-r--  2 clifford clifford 1.9G Jul  8 02:23 cgi-server-2019-07-08.tar.gz
-rwxrw-r-- 15 clifford clifford  17G Jun 24 06:36 clang-container-2019-06-24.tar.gz
-rwxrw-r--  8 clifford clifford  17G Jul  1 06:50 clang-container-2019-07-01.tar.gz
-rwxrw-r--  1 clifford clifford  17G Jul  8 07:16 clang-container-2019-07-08.tar.gz
-rw-r--r-- 48 clifford clifford 818M Nov 30  2018 dnsproxy-container-2018.11.30.tar.gz
-rwxrw-r-- 16 clifford clifford 1.1G Jun 24 02:20 gitea-server-2019-06-24.tar.gz
-rwxrw-r--  9 clifford clifford 1.2G Jul  1 02:28 gitea-server-2019-07-01.tar.gz
-rwxrw-r--  2 clifford clifford 1.2G Jul  8 02:28 gitea-server-2019-07-08.tar.gz
-rw-r--r-- 48 clifford clifford 813M Nov 30  2018 home-openvpn-container-2018.11.30.tar.gz
-rwxrw-r-- 16 clifford clifford 2.2G Jun 24 02:31 mail-server-2-2019-06-24.tar.gz
-rwxrw-r--  9 clifford clifford 2.2G Jul  1 02:40 mail-server-2-2019-07-01.tar.gz
-rwxrw-r--  2 clifford clifford 2.2G Jul  8 02:41 mail-server-2-2019-07-08.tar.gz
-rwxrw-r-- 16 clifford clifford 1.2G Jun 24 02:35 mariadb-server-2019-06-24.tar.gz
-rwxrw-r--  9 clifford clifford 1.2G Jul  1 02:45 mariadb-server-2019-07-01.tar.gz
-rwxrw-r--  2 clifford clifford 1.2G Jul  8 02:47 mariadb-server-2019-07-08.tar.gz
-rwxrw-r-- 16 clifford clifford 4.1G Jun 24 02:47 mattermost-server-2019-06-24.tar.gz
-rwxrw-r--  9 clifford clifford 4.4G Jul  1 02:59 mattermost-server-2019-07-01.tar.gz
-rwxrw-r--  2 clifford clifford 4.4G Jul  8 03:09 mattermost-server-2019-07-08.tar.gz
-rwxrw-r-- 16 clifford clifford  11G Jun 24 03:29 mm-mobile-dev-container-2019-06-24.tar.gz
-rwxrw-r--  9 clifford clifford  11G Jul  1 03:44 mm-mobile-dev-container-2019-07-01.tar.gz
-rwxrw-r--  2 clifford clifford  11G Jul  8 03:54 mm-mobile-dev-container-2019-07-08.tar.gz
-rw-r--r-- 48 clifford clifford 766M Nov 30  2018 nginx-container-2018.11.30.tar.gz
-rwxrw-r-- 16 clifford clifford 3.1G Jun 24 03:41 nginx-php-server-2019-06-24.tar.gz
-rwxrw-r--  9 clifford clifford 3.1G Jul  1 03:56 nginx-php-server-2019-07-01.tar.gz
-rwxrw-r--  2 clifford clifford 3.1G Jul  8 04:05 nginx-php-server-2019-07-08.tar.gz
-rwxrw-r-- 16 clifford clifford 709M Jun 24 03:44 nginx-server-2019-06-24.tar.gz
-rwxrw-r--  9 clifford clifford 717M Jul  1 03:59 nginx-server-2019-07-01.tar.gz
-rwxrw-r--  2 clifford clifford 717M Jul  8 04:08 nginx-server-2019-07-08.tar.gz
-rwxrw-r-- 16 clifford clifford  28G Jun 24 05:06 plex-2019-06-24.tar.gz
-rwxrw-r--  9 clifford clifford  28G Jul  1 05:21 plex-2019-07-01.tar.gz
-rwxrw-r--  2 clifford clifford  33G Jul  8 05:43 plex-2019-07-08.tar.gz
-rwxrw-r-- 16 clifford clifford 1.1G Jun 24 05:10 push-proxy-server-2019-06-24.tar.gz
-rwxrw-r--  9 clifford clifford 1.1G Jul  1 05:25 push-proxy-server-2019-07-01.tar.gz
-rwxrw-r--  2 clifford clifford 1.1G Jul  8 05:46 push-proxy-server-2019-07-08.tar.gz
-rwxrw-r-- 15 clifford clifford 886M Jun 24 06:39 scratch-container-2019-06-24.tar.gz
-rwxrw-r--  8 clifford clifford 888M Jul  1 06:53 scratch-container-2019-07-01.tar.gz
-rwxrw-r--  1 clifford clifford 894M Jul  8 07:19 scratch-container-2019-07-08.tar.gz
-rwxrw-r-- 48 clifford clifford 780M Sep  2  2018 tvheadend-server-090218.tar.gz
-rwxrw-r-- 48 clifford clifford 176M Feb 25 04:12 vmail-2019-02-19.tar.gz.enc.gz
0 Likes

#16

Well, well. I’ve finally gotten to it.
I’ve found the console of the proxmox Server that’s running the container. So far, so good.
The lxc command on it’s own doesn’t even exist.
Through some research i found, the lxc-snapshot should be what i’m looking at. I’ve run lxc-snapshot -n 200 200-snapshot which should create a snapshot of the container 200. It created a “snaps” directory under /var/lib/lxc/200/snaps but there’s nothing in there. No idea how to tell, if the snapshot worked and if it’s restorable. lxc-snapshot -n 200 -L shows no snapshots. lxc-snapshot does not provide any output.

0 Likes