Community discussions

MikroTik App
 
nieprzem
just joined
Topic Author
Posts: 7
Joined: Thu Apr 04, 2024 10:58 am

Container backup

Thu May 09, 2024 4:25 pm

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 :)
Image
Image
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.
 
optio
Forum Veteran
Forum Veteran
Posts: 710
Joined: Mon Dec 26, 2022 2:57 pm

Re: Container backup

Thu May 09, 2024 7:53 pm

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.
 
nieprzem
just joined
Topic Author
Posts: 7
Joined: Thu Apr 04, 2024 10:58 am

Re: Container backup

Thu May 09, 2024 8:03 pm

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?
 
optio
Forum Veteran
Forum Veteran
Posts: 710
Joined: Mon Dec 26, 2022 2:57 pm

Re: Container backup

Thu May 09, 2024 8:21 pm

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.
 
User avatar
patrikg
Member Candidate
Member Candidate
Posts: 280
Joined: Thu Feb 07, 2013 6:38 pm
Location: Stockholm, Sweden

Re: Container backup

Thu May 09, 2024 8:59 pm

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.
 
optio
Forum Veteran
Forum Veteran
Posts: 710
Joined: Mon Dec 26, 2022 2:57 pm

Re: Container backup  Topic is solved

Thu May 09, 2024 9:01 pm

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.
 
nieprzem
just joined
Topic Author
Posts: 7
Joined: Thu Apr 04, 2024 10:58 am

Re: Container backup

Thu May 09, 2024 10:58 pm

@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.

Image

Who is online

Users browsing this forum: No registered users and 1 guest