Category Archives: How-to

  • 0

Reduce Proxmox LXC Backup Size and Time

Category : How-to

Get Social!

Proxmox backs up guests byte-for-byte in a compressed archive. Looking at LXC backups specifically, the file system is compressed into the target backup file with just a few exceptions – temp files aren’t included. You can also add your own exceptions by editing the vzdump.conf to exclude specific file patterns.

All that said, one of the biggest disk space wasters is the cache directory for apt which caches the installation packages for software you have installed. This can generally be safely removed on internet connected machines which will reduce your overall backup size.

For example, a newly created Debian LXC that’s been recently updated shows a total of 206MB of disk used.

After clearing this with the command apt-get clean we can see the space has mostly been freed.

Considering this whole container is only consuming approximately 1GB of disk space, 200MB is quite significant.

vzdump hooks

Now we can see how much space we can save, we need to make Proxmox issue the apt-get clean command before it creates the backup of our container.

vzdump, the utility which Proxmox uses to perform backups has the ability to call a script for various stages of the backup process – these stages are:

  • backup-start
  • backup-end
  • backup-abort
  • log-end
  • pre-stop
  • pre-restart
  • post-restart

We can use these hooks to run our own commands at any of these points of the backup. For the goal of this blog post, we want to run the apt-get clean command at the point of backup-start.

Create a script on your Proxmox host with the following content:

Now edit your vzdump.conf file and add the following line to point to your new script. Remember to change the location of where your script is – I’ve just saved mine in /root/.

 


  • 0

Gitlab Runner Error: sudo: no tty present and no askpass program specified

Get Social!

After issuing the first build on a dynamically created Container I came across the following build error when running a command with sudo.

The error is caused by trying to run a command with sudo, however the calling user has not been authorised to use sudo. The error isn’t helpful, and doesn’t really spell out where to go, but adding the calling user to the sudoers file will save the day.

Solution

Open up the sudoers file for editing in your favorite editor.

And add your gitlab runner user to the bottom. If you installed your gitlab runner from the official apt repositories then your gitlab-runner process will run under the gitlab-runner user.

Add the following to the bottom of the file:

Retry your build and you should be back in business!

 


  • 0

Scripted Install of Oracle Java 8 on Ubuntu 16.04

Get Social!

Please see Install Oracle Java In Debian/ Ubuntu using apt-get for more information.

 


  • 0

Rename a Proxmox Host

Category : How-to

Get Social!

Renaming a Linux server’s hostname is usually a trivial task, and that’s no Different to a Proxmox server providing it’s not part of a cluster. If your machine is in a cluster then things get a bit more complicated and that’s a blog subject for another day.

For a single node machine it’s simple – Proxmox is Debian under the hood so simply follow the usual Debian process:

Change the hostname file to contain your new hostname

To save having to restart, you can also run the hostname command to implement the change on a running machine. Otherwise you’ll need to reboot your server to pick up the change.

Next, edit your /etc/hostname file and change all occurrences of the old hostname with the new one.


  • 0

OBI formatting grand totals – without XML!

Get Social!

Recently I needed to have some conditionally formated grand total rows in OBI. I remember years ago hacking around with the XML which is far from ideal. I then realised it could be done another way, here is the example:

 

Create an analysis with a measure column:

Apply the conditional format on the Actual % column

This should result in the following analysis

This is the special bit, add a new calculated item on the column where you want the total

Select the Function (aggregation Rule) and add in all of the values

Now the totals will be applied to the analysis

You can format this calculated row using the format option on the calculated item window


  • 0

Start/ Stop Container Using The Proxmox Web API in Bash

Category : How-to

Get Social!

The Proxmox Web API can perform any actions available in the front end Web. By implementing a REST API, all commands have been exposed and can be used programatically.

In this example we’ll use Bash to call the Proxmox Web API with our authentication token to start and stop an existing LXC Container.

See this post for an introduction to the Proxmox Web API, including all available API commands.

To issue API requests you’ll need to ensure you have already generated an authentication ticket which is described in Parse Proxmox Web API authentication ticket and the CSRFPreventionToken in Bash.

Once you have the authentication ticket you’ll need to call the Proxmox API using curl and parse the result. Use the below scripts and substitute the values as required:

Start an LXC Container

  • TICKET is the authentication ticket that was produced in the Parse Proxmox Web API authentication ticket and the CSRFPreventionToken in Bash post. Ideally you would programatically call the authentication routine and then pass the values straight into the below API calls.
  • CSRF is produced in the same way as TICKET. It’s actually only required when writing data to the API but there is no harm in always including it.
  • HOST is the host or IP address of the Proxmox server.
  • NODE is the node name of the Proxmox server that the LXC Container resides on.
  • TARGET_VM  is the VMID of the LXC Container.

If $START_TASK_RESULT doesn’t come back with null or empty then the command has successfully executed.

Stop an LXC Container

Stopping a VM in Proxmox is very similar to starting one, with just a slight change to the API URL call. All other options are the same as the above section ‘Start an LXC Container’.

If $STOP_TASK_RESULT doesn’t come back with null or empty then the command has successfully executed.