Container backup

I would like to write a script to backup container in case external USB drive fails.

This is how my setup container looks:

/container/ print
 0 name="x" tag="adguard/adguardhome:latest" os="linux" arch="arm64"
   interface=veth1-adguard root-dir=usb1/adguard mounts=adguard-workdir,adguard-conf dns="" logging=yes
   start-on-boot=yes status=running
/container/ mounts/ print
 0 name="adguard-workdir" src="/usb1/adguard-workdir" dst="/opt/adguardhome/work"
 1 name="adguard-conf" src="/usb1/adguard-conf" dst="/opt/adguardhome/conf"

But when I take a look on WinBox → Files then the only things I see are couple of directories called container store. Once I download this to Windows computer it size is 0 bytes, which seems a bit wired. Which I am missing or do not know about :slight_smile:

PS. At the first start of adguard container I saw for a second some files under adguard-config but then i changed to container store.

I assume USB is formatted as FAT because it can be browsed on Windows?
See https://help.mikrotik.com/docs/display/ROS/Container:

Container use example
Prerequisites:

  • RouterOS device with RouterOS v7.4beta or later and installed Container package

  • Physical access to a device to enable container mode

  • Attached hard drive or USB drive for storage - formatted as ext3/ext4

When is formatted as ext3/ext4 FS directory is visible on Linux or other system/app which supports this FS and can be backuped.

The screenshot from Windows it is just after downloading the usb1 content via WinBox (right click → download).

It is formatted as ext4. How to handle it then? Should I mount it as SMB and try read on Linux machine?

You can just insert USB drive to Linux machine or VM and mount it inside Linux, use tar for backuping to preserve special files (like in /dev), permissions and symlinks on dirs/files, example.

Not sure it can be done without detaching USB from MT device, over SMB you cannot get permissions and other above mentioned which are necessary for proper FS backup.

P.S.
It should be possible to do it inside running container using its shell from ROS terminal, like described here and then transfer backup archive from mounted directory (not as container store) in ROS to local OS over Winbox, not sure if Adguard container image has tar, but it should be possible to install it over package manager (apt/apk - depending on which Linux OS container image is based) from container shell.

Use the tools you have in the Windows environment you have.
Like scp like something this from command prompt:

scp admin@192.168.88.1:/usb1/adguard .

And for the zero bytes file, i think you have to stop the container before the you could access the files.

And did you tried to backup/restore root OS dir like that?

@nieprzem generally it not needed to backup containers root dir, just mounts which are preserving configuration and other files that are needed for service to be restored as configured. Then these directories can be mounted not as container store and files are visible in ROS and can be copied elsewhere from WInbox. To see files in ROS in mounted container directory delete .type file (existence of this file in dir hides dir content in ROS) from that dir (do not do this in root-dir!) from container shell or when creating container mount already existing directory which doesn’t contain that file.

@optio thanks for the tip.
I have created adguard-conf directory and recreated container. Now I am able to see the adguard conf file, which could be send later on using fetch tool to local FTP server.
Thank you.