RAM-Disk for Docker status/log files


Recommended Posts

I successfully tested the following version with Unraid 6.12.3

 

# -------------------------------------------------
# RAM-Disk for Docker json/log files v1.5
# -------------------------------------------------

# check compatibility
echo -e "ce45b19ceea8837f8143b8a5b64663f2 /etc/rc.d/rc.docker\n9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor" | md5sum --check --status && compatible=1
if [[ $compatible ]]; then

  # create RAM-Disk on starting the docker service
  sed -i '/nohup/i \
  # move json/logs to ram disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  mountpoint -q /var/lib/docker/containers || mount -t tmpfs tmpfs /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be mounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk created' /etc/rc.d/rc.docker

  # remove RAM-Disk on stopping the docker service
  sed -i '/tear down the bridge/i \
  # backup json/logs and remove RAM-Disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  umount /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be unmounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  if [[ -d /var/lib/docker_bind ]]; then umount /var/lib/docker_bind || logger -t docker Error: RAM-Disk bind unmount failed while docker stops!; fi\
  logger -t docker RAM-Disk removed' /etc/rc.d/rc.docker

  # Automatically backup Docker RAM-Disk
  sed -i '/^<?PHP$/a \
  $sync_interval_minutes=30;\
  if ( ! ((date("i") * date("H") * 60 + date("i")) % $sync_interval_minutes) && file_exists("/var/lib/docker/containers")) {\
    exec("\
      [[ ! -d /var/lib/docker_bind ]] && mkdir /var/lib/docker_bind\
      if ! mountpoint -q /var/lib/docker_bind; then\
        if ! mount --bind /var/lib/docker /var/lib/docker_bind; then\
          logger -t docker Error: RAM-Disk bind mount failed!\
        fi\
      fi\
      if mountpoint -q /var/lib/docker_bind; then\
        rsync -aH --delete /var/lib/docker/containers/ /var/lib/docker_bind/containers && logger -t docker Success: Backup of RAM-Disk created.\
        umount -l /var/lib/docker_bind\
      else\
        logger -t docker Error: RAM-Disk bind mount failed!\
      fi\
    ");\
  }' /usr/local/emhttp/plugins/dynamix/scripts/monitor

else
  logger -t docker "Error: RAM-Disk Mod found incompatible files: $(md5sum /etc/rc.d/rc.docker /usr/local/emhttp/plugins/dynamix/scripts/monitor | xargs)"
fi

 

In addition the modifications apply only if the files are compatible. This should prevent errors if Limetech changes the files in one of the future Unraid versions again.

 

  • Thanks 3
Link to comment

Unfortunately, even with the updated script, I still get an error message when stopping Docker:

 

Jul 28 20:03:42 smartserver root: stopping dockerd ...
Jul 28 20:03:44 smartserver root: umount: /var/lib/docker_bind: not mounted.
Jul 28 20:03:44 smartserver docker: Error: RAM-Disk bind unmount failed while docker stops!
Jul 28 20:03:44 smartserver docker: RAM-Disk removed
Jul 28 20:03:44 smartserver emhttpd: shcmd (222): umount /var/lib/docker

 

 

But the RAM-Disk seems to be created without errors when starting Docker and I also get the Success message every 30 minutes

 

Jul 28 20:06:07 smartserver root: starting dockerd ...
Jul 28 20:06:07 smartserver docker: RAM-Disk created
root@smartserver:~# mount | grep tmpfs | grep docker
tmpfs on /var/lib/docker/containers type tmpfs (rw,relatime,inode64)
tmpfs on /mnt/cache/system/docker/docker/containers type tmpfs (rw,relatime,inode64)
Link to comment
3 hours ago, kennymc.c said:

Unfortunately, even with the updated script, I still get an error message when stopping Docker:

 

I've checked that and found out that the bug is even present in the older version and the last Unraid version. And actually the problematic line is doing a useless step and that's why I removed it:

 

# -------------------------------------------------
# RAM-Disk for Docker json/log files v1.6
# -------------------------------------------------

# check compatibility
echo -e "ce45b19ceea8837f8143b8a5b64663f2 /etc/rc.d/rc.docker\n9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor" | md5sum --check --status && compatible=1
if [[ $compatible ]]; then

  # create RAM-Disk on starting the docker service
  sed -i '/nohup/i \
  # move json/logs to ram disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  mountpoint -q /var/lib/docker/containers || mount -t tmpfs tmpfs /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be mounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk created' /etc/rc.d/rc.docker

  # remove RAM-Disk on stopping the docker service
  sed -i '/tear down the bridge/i \
  # backup json/logs and remove RAM-Disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  umount /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be unmounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk removed' /etc/rc.d/rc.docker

  # Automatically backup Docker RAM-Disk
  sed -i '/^<?PHP$/a \
  $sync_interval_minutes=30;\
  if ( ! ((date("i") * date("H") * 60 + date("i")) % $sync_interval_minutes) && file_exists("/var/lib/docker/containers")) {\
    exec("\
      [[ ! -d /var/lib/docker_bind ]] && mkdir /var/lib/docker_bind\
      if ! mountpoint -q /var/lib/docker_bind; then\
        if ! mount --bind /var/lib/docker /var/lib/docker_bind; then\
          logger -t docker Error: RAM-Disk bind mount failed!\
        fi\
      fi\
      if mountpoint -q /var/lib/docker_bind; then\
        rsync -aH --delete /var/lib/docker/containers/ /var/lib/docker_bind/containers && logger -t docker Success: Backup of RAM-Disk created.\
        umount -l /var/lib/docker_bind\
      else\
        logger -t docker Error: RAM-Disk bind mount failed!\
      fi\
    ");\
  }' /usr/local/emhttp/plugins/dynamix/scripts/monitor

else
  logger -t docker "Error: RAM-Disk Mod found incompatible files: $(md5sum /etc/rc.d/rc.docker /usr/local/emhttp/plugins/dynamix/scripts/monitor | xargs)"
fi

 

 

Further explanation:

The backup part creates the directory "/var/lib/docker_bind" and a mount on it. After the backup is done the mount is removed. So it doesn't make sense to remove the mount additionally through the part which gets executed while docker is stopping (as the mount exists only while the backup is running). I think my actual idea was to remove the directory "/var/lib/docker_bind", but finally this is an absolutely unnecessary step as leaving an empty directory does not influence anything on the system. Actually this even saves the additional step to re-create the directory on the next docker start.

  • Thanks 1
Link to comment
  • 4 weeks later...
On 7/27/2023 at 1:10 AM, mgutt said:

In addition the modifications apply only if the files are compatible. This should prevent errors if Limetech changes the files in one of the future Unraid versions again.

 

Looks like they did in 6.12.4 (RC18)

Aug 22 22:06:41 Unraid-1 docker: Error: RAM-Disk Mod found incompatible files: 56bd9d7d271d027f627ddc33c801b835 /etc/rc.d/rc.docker 9f093a24ae5c2e804088ed4081027112 /usr/local/emhttp/plugins/dynamix/scripts/monitor

 

Link to comment

You can either change the checksum or delete the compatibility check. Works on 12.4


 

# -------------------------------------------------
# RAM-Disk for Docker json/log files v1.6 for 6.12.4
# -------------------------------------------------

# check compatibility
echo -e "45361157ef841f9a32a984b056da0564 /etc/rc.d/rc.docker\n9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor" | md5sum --check --status && compatible=1
if [[ $compatible ]]; then

  # create RAM-Disk on starting the docker service
  sed -i '/nohup/i \
  # move json/logs to ram disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  mountpoint -q /var/lib/docker/containers || mount -t tmpfs tmpfs /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be mounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk created' /etc/rc.d/rc.docker

  # remove RAM-Disk on stopping the docker service
  sed -i '/tear down the bridge/i \
  # backup json/logs and remove RAM-Disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  umount /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be unmounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk removed' /etc/rc.d/rc.docker

  # Automatically backup Docker RAM-Disk
  sed -i '/^<?PHP$/a \
  $sync_interval_minutes=30;\
  if ( ! ((date("i") * date("H") * 60 + date("i")) % $sync_interval_minutes) && file_exists("/var/lib/docker/containers")) {\
    exec("\
      [[ ! -d /var/lib/docker_bind ]] && mkdir /var/lib/docker_bind\
      if ! mountpoint -q /var/lib/docker_bind; then\
        if ! mount --bind /var/lib/docker /var/lib/docker_bind; then\
          logger -t docker Error: RAM-Disk bind mount failed!\
        fi\
      fi\
      if mountpoint -q /var/lib/docker_bind; then\
        rsync -aH --delete /var/lib/docker/containers/ /var/lib/docker_bind/containers && logger -t docker Success: Backup of RAM-Disk created.\
        umount -l /var/lib/docker_bind\
      else\
        logger -t docker Error: RAM-Disk bind mount failed!\
      fi\
    ");\
  }' /usr/local/emhttp/plugins/dynamix/scripts/monitor

else
  logger -t docker "Error: RAM-Disk Mod found incompatible files: $(md5sum /etc/rc.d/rc.docker /usr/local/emhttp/plugins/dynamix/scripts/monitor | xargs)"
fi

 

Edited by Mainfrezzer
  • Like 3
Link to comment
  • 1 month later...
On 9/3/2023 at 11:09 PM, Mainfrezzer said:

You can either change the checksum or delete the compatibility check. Works on 12.4


 

# -------------------------------------------------
# RAM-Disk for Docker json/log files v1.6 for 6.12.4
# -------------------------------------------------

# check compatibility
echo -e "45361157ef841f9a32a984b056da0564 /etc/rc.d/rc.docker\n9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor" | md5sum --check --status && compatible=1
if [[ $compatible ]]; then

  # create RAM-Disk on starting the docker service
  sed -i '/nohup/i \
  # move json/logs to ram disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  mountpoint -q /var/lib/docker/containers || mount -t tmpfs tmpfs /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be mounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk created' /etc/rc.d/rc.docker

  # remove RAM-Disk on stopping the docker service
  sed -i '/tear down the bridge/i \
  # backup json/logs and remove RAM-Disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  umount /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be unmounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk removed' /etc/rc.d/rc.docker

  # Automatically backup Docker RAM-Disk
  sed -i '/^<?PHP$/a \
  $sync_interval_minutes=30;\
  if ( ! ((date("i") * date("H") * 60 + date("i")) % $sync_interval_minutes) && file_exists("/var/lib/docker/containers")) {\
    exec("\
      [[ ! -d /var/lib/docker_bind ]] && mkdir /var/lib/docker_bind\
      if ! mountpoint -q /var/lib/docker_bind; then\
        if ! mount --bind /var/lib/docker /var/lib/docker_bind; then\
          logger -t docker Error: RAM-Disk bind mount failed!\
        fi\
      fi\
      if mountpoint -q /var/lib/docker_bind; then\
        rsync -aH --delete /var/lib/docker/containers/ /var/lib/docker_bind/containers && logger -t docker Success: Backup of RAM-Disk created.\
        umount -l /var/lib/docker_bind\
      else\
        logger -t docker Error: RAM-Disk bind mount failed!\
      fi\
    ");\
  }' /usr/local/emhttp/plugins/dynamix/scripts/monitor

else
  logger -t docker "Error: RAM-Disk Mod found incompatible files: $(md5sum /etc/rc.d/rc.docker /usr/local/emhttp/plugins/dynamix/scripts/monitor | xargs)"
fi

 

I am on 6.12.4, going to try this script. Was on 6.9.x and the old script worked great. With this new script, do I still need to edit the Paraments on my Dockers individually and extra line of code @mgutt @Mainfrezzer? BTW, how do you get the checksum for this script? I see two unique checksum codes. Thank you!

Edited by pervin_1
Link to comment
16 hours ago, pervin_1 said:

Wondering if anyone can help me with questions above? Thanks! 

 

If you look at this line:

echo -e "45361157ef841f9a32a984b056da0564 /etc/rc.d/rc.docker\n9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor" | md5sum --check --status && compatible=1

 

There are two files in the format of "md5_checksum path_to_file":

45361157ef841f9a32a984b056da0564 /etc/rc.d/rc.docker

9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor

 

You can use md5sum to generate new checksums on those two files, like:

md5sum /etc/rc.d/rc.docker

 

Sounds like @Mainfrezzer's code already includes the new checksums for 6.12.4. But you can double check yourself if you want.

Edited by Phoenix Down
Link to comment
On 10/9/2023 at 11:33 AM, Phoenix Down said:

 

If you look at this line:

echo -e "45361157ef841f9a32a984b056da0564 /etc/rc.d/rc.docker\n9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor" | md5sum --check --status && compatible=1

 

There are two files in the format of "md5_checksum path_to_file":

45361157ef841f9a32a984b056da0564 /etc/rc.d/rc.docker

9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor

 

You can use md5sum to generate new checksums on those two files, like:

md5sum /etc/rc.d/rc.docker

 

Sounds like @Mainfrezzer's code already includes the new checksums for 6.12.4. But you can double check yourself if you want.

Ran two md5sum checks on rc.docker and scripts monitor, the checksums are different. Which means I should change the compatibility code, correct? 

 

Thank you!

Link to comment
2 hours ago, pervin_1 said:

Ran two md5sum checks on rc.docker and scripts monitor, the checksums are different. Which means I should change the compatibility code, correct? 

 

Thank you!

If your Unraid version is different than @Mainfrezzer's code example, then it's possible those files are also different. So yes, you should update the RAM DIsk code with your own checksums. Note that doing this doesn't mean the RAM Disk code won't have any issues, just that the code won't abort itself. It might or might not have any issues, but we don't know until someone tries it out whenever a few version of Unraid comes out.

Link to comment
On 10/12/2023 at 3:49 PM, Phoenix Down said:

If your Unraid version is different than @Mainfrezzer's code example, then it's possible those files are also different. So yes, you should update the RAM DIsk code with your own checksums. Note that doing this doesn't mean the RAM Disk code won't have any issues, just that the code won't abort itself. It might or might not have any issues, but we don't know until someone tries it out whenever a few version of Unraid comes out.

It’s the same version. I did run without the compatibility check, and everything is working from what I see. The RAM disk shows is created in the logs. But I am gonna update it and run again. 
 

I remember we used to change the settings for each docker and added additional parameters. It sounds like is no longer the case with the updated script? 

Link to comment
On 10/12/2023 at 3:49 PM, Phoenix Down said:

If your Unraid version is different than @Mainfrezzer's code example, then it's possible those files are also different. So yes, you should update the RAM DIsk code with your own checksums. Note that doing this doesn't mean the RAM Disk code won't have any issues, just that the code won't abort itself. It might or might not have any issues, but we don't know until someone tries it out whenever a few version of Unraid comes out.

I am on the 12.4, and updated the compatibility code with my own checksums, and it got aborted upon the boot

 

Error: RAM-Disk Mod found incompatible files: 45361157ef841f9a32a984b056da0564 /etc/rc.d/rc.docker 9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor

 

 

Link to comment
1 hour ago, pervin_1 said:

I am on the 12.4, and updated the compatibility code with my own checksums, and it got aborted upon the boot

 

Error: RAM-Disk Mod found incompatible files: 45361157ef841f9a32a984b056da0564 /etc/rc.d/rc.docker 9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor

 

 

Check to make sure you copy and pasted the correct checksums into the RAM disk script. Maybe you missed a digit at the end.

Link to comment
1 hour ago, Phoenix Down said:

Check to make sure you copy and pasted the correct checksums into the RAM disk script. Maybe you missed a digit at the end.

I went ahead and left the checksums from @Mainfrezzer's script unchanged. Its weird that I initially changed the checksums with my own, and the script aborted itself and threw the error code from @Mainfrezzer's original checksum codes, IDK why. Everything it seems to be working now. I still get about ~5Gb writen per day. But without the script, its about 32Gb daily. There are still uncessary writes, but I am very happy. My two cache drives are Pro 980 Samsung 1Tb models, and they are supposed to last about 600TBW. Which means about 300 years lol. 

 

Thank you!

 

 

Thank you!

Link to comment
  • 1 month later...

For 6.12.5-rc1 will update/edit this post as we go along
For 6.12.5 (Does work with 6.12.6 aswell)


 

# -------------------------------------------------
# RAM-Disk for Docker json/log files v1.6 for 6.12.5
# -------------------------------------------------

# check compatibility
echo -e "a26fd1e4fae583e52a2a80b90b3d5500 /etc/rc.d/rc.docker\n9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor" | md5sum --check --status && compatible=1
if [[ $compatible ]]; then

  # create RAM-Disk on starting the docker service
  sed -i '/nohup/i \
  # move json/logs to ram disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  mountpoint -q /var/lib/docker/containers || mount -t tmpfs tmpfs /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be mounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk created' /etc/rc.d/rc.docker

  # remove RAM-Disk on stopping the docker service
  sed -i '/tear down the bridge/i \
  # backup json/logs and remove RAM-Disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  umount /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be unmounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk removed' /etc/rc.d/rc.docker

  # Automatically backup Docker RAM-Disk
  sed -i '/^<?PHP$/a \
  $sync_interval_minutes=30;\
  if ( ! ((date("i") * date("H") * 60 + date("i")) % $sync_interval_minutes) && file_exists("/var/lib/docker/containers")) {\
    exec("\
      [[ ! -d /var/lib/docker_bind ]] && mkdir /var/lib/docker_bind\
      if ! mountpoint -q /var/lib/docker_bind; then\
        if ! mount --bind /var/lib/docker /var/lib/docker_bind; then\
          logger -t docker Error: RAM-Disk bind mount failed!\
        fi\
      fi\
      if mountpoint -q /var/lib/docker_bind; then\
        rsync -aH --delete /var/lib/docker/containers/ /var/lib/docker_bind/containers && logger -t docker Success: Backup of RAM-Disk created.\
        umount -l /var/lib/docker_bind\
      else\
        logger -t docker Error: RAM-Disk bind mount failed!\
      fi\
    ");\
  }' /usr/local/emhttp/plugins/dynamix/scripts/monitor

else
  logger -t docker "Error: RAM-Disk Mod found incompatible files: $(md5sum /etc/rc.d/rc.docker /usr/local/emhttp/plugins/dynamix/scripts/monitor | xargs)"
fi

 

Edited by Mainfrezzer
  • Like 1
  • Thanks 6
Link to comment
  • 5 weeks later...

6.12.7-rc2
As before, will update as we go along.

6.12.10
 

# -------------------------------------------------
# RAM-Disk for Docker json/log files v1.6 for 6.12.10
# -------------------------------------------------

# check compatibility
echo -e "8d6094c1d113eb67411e18abc8aaf15d /etc/rc.d/rc.docker\n9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor" | md5sum --check --status && compatible=1
if [[ $compatible ]]; then

  # create RAM-Disk on starting the docker service
  sed -i '/nohup/i \
  # move json/logs to ram disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  mountpoint -q /var/lib/docker/containers || mount -t tmpfs tmpfs /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be mounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk created' /etc/rc.d/rc.docker

  # remove RAM-Disk on stopping the docker service
  sed -i '/tear down the bridge/i \
  # backup json/logs and remove RAM-Disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  umount /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be unmounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk removed' /etc/rc.d/rc.docker

  # Automatically backup Docker RAM-Disk
  sed -i '/^<?PHP$/a \
  $sync_interval_minutes=30;\
  if ( ! ((date("i") * date("H") * 60 + date("i")) % $sync_interval_minutes) && file_exists("/var/lib/docker/containers")) {\
    exec("\
      [[ ! -d /var/lib/docker_bind ]] && mkdir /var/lib/docker_bind\
      if ! mountpoint -q /var/lib/docker_bind; then\
        if ! mount --bind /var/lib/docker /var/lib/docker_bind; then\
          logger -t docker Error: RAM-Disk bind mount failed!\
        fi\
      fi\
      if mountpoint -q /var/lib/docker_bind; then\
        rsync -aH --delete /var/lib/docker/containers/ /var/lib/docker_bind/containers && logger -t docker Success: Backup of RAM-Disk created.\
        umount -l /var/lib/docker_bind\
      else\
        logger -t docker Error: RAM-Disk bind mount failed!\
      fi\
    ");\
  }' /usr/local/emhttp/plugins/dynamix/scripts/monitor

else
  logger -t docker "Error: RAM-Disk Mod found incompatible files: $(md5sum /etc/rc.d/rc.docker /usr/local/emhttp/plugins/dynamix/scripts/monitor | xargs)"
fi

 

Edited by Mainfrezzer
  • Like 6
  • Thanks 3
Link to comment
  • 1 month later...
On 2/13/2024 at 5:40 AM, Mainfrezzer said:

6.12.7-rc2
As before, will update as we go along.

6.12.8
 

# -------------------------------------------------
# RAM-Disk for Docker json/log files v1.6 for 6.12.8
# -------------------------------------------------

# check compatibility
echo -e "8d6094c1d113eb67411e18abc8aaf15d /etc/rc.d/rc.docker\n9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor" | md5sum --check --status && compatible=1
if [[ $compatible ]]; then

  # create RAM-Disk on starting the docker service
  sed -i '/nohup/i \
  # move json/logs to ram disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  mountpoint -q /var/lib/docker/containers || mount -t tmpfs tmpfs /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be mounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk created' /etc/rc.d/rc.docker

  # remove RAM-Disk on stopping the docker service
  sed -i '/tear down the bridge/i \
  # backup json/logs and remove RAM-Disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  umount /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be unmounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk removed' /etc/rc.d/rc.docker

  # Automatically backup Docker RAM-Disk
  sed -i '/^<?PHP$/a \
  $sync_interval_minutes=30;\
  if ( ! ((date("i") * date("H") * 60 + date("i")) % $sync_interval_minutes) && file_exists("/var/lib/docker/containers")) {\
    exec("\
      [[ ! -d /var/lib/docker_bind ]] && mkdir /var/lib/docker_bind\
      if ! mountpoint -q /var/lib/docker_bind; then\
        if ! mount --bind /var/lib/docker /var/lib/docker_bind; then\
          logger -t docker Error: RAM-Disk bind mount failed!\
        fi\
      fi\
      if mountpoint -q /var/lib/docker_bind; then\
        rsync -aH --delete /var/lib/docker/containers/ /var/lib/docker_bind/containers && logger -t docker Success: Backup of RAM-Disk created.\
        umount -l /var/lib/docker_bind\
      else\
        logger -t docker Error: RAM-Disk bind mount failed!\
      fi\
    ");\
  }' /usr/local/emhttp/plugins/dynamix/scripts/monitor

else
  logger -t docker "Error: RAM-Disk Mod found incompatible files: $(md5sum /etc/rc.d/rc.docker /usr/local/emhttp/plugins/dynamix/scripts/monitor | xargs)"
fi

 

looks good for 6.12.10

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.