Backup own settings/files

Hi!

I would like to backup some of my “own” files like some python scrips or /etc/sysconfig/firewall.local.
I’ve read https://community.ipfire.org/t/how-to-backup-addons/4846/11 that adding a text file to subfolder

/var/ipfire/backup/addons/includes

will do the job. Looking into the existing file haproxy and its content

/etc/haproxy/certs
/etc/haproxy/haproxy.cfg

it looks like adding all necessary files and their path will backup the files in question, right?
May I further assume that this file

/var/ipfire/backup/include.user

is the better option to add those files?
Can I use a syntax like

/root/metrics/.

to backup whole directories, including files and nested subfolders?

Michael

Hi @Hellfire,

the /var/ipfire/backup/addons/includes directory is intended for the backup lists for any installed addon to be stored. I can’t be certain that anything additional added in there will stay in place during an upgrade.

Yes, this is absolutely the correct place to list the files/directories that you want to be backed up. They will then be included as part of the overall IPFire backup.

/root/metrics/
will backup everything in the metrics directory including any subdirectories.

You can use wildcards to specify specific files in directories as well.
/root/metrics/disk-space*
will save all files in that directory starting with disk-space.
You can also add multiple lines for that directory with different wildcards.

You could probably use standard regex commands but I don’t know that for certain and am not familiar enough with the backup perl code to know that without looking in some detail but you could give it a try and see if it worked.

3 Likes

Thanks Adolf for your reply!

A quick test already showed me that I’m correct and you of course, too. I had a further look into the backup Perl script /var/ipfire/backup/bin/backup.pl, too, that showed me that regular expressions may not apply since the script obviously reads line by line and backs up the given file or folder.

But I may be wrong in interpreting the perl script lines:

	tar cvzf "${filename}" \
		--exclude-from="/var/ipfire/backup/exclude" \
		--exclude-from="/var/ipfire/backup/exclude.user" \
		$(process_includes "/var/ipfire/backup/include" "/var/ipfire/backup/include.user") \
		"$@"

Thanks,
Michael

Hi Michael,

I looked through the tar manual and found a section on wildcards. So you can specify for instance that all files in a directory should be backed up except those that end in pa by adding the line in your example of
/root/metrics/*[!p,a]

I tested this out and was able to filter out all files ending in pa but including all the other files, even if they had pa within the filename somewhere.

The following is the link to the wildcards section in the tar manual
https://www.gnu.org/software/tar/manual/tar.html#wildcards

3 Likes