I like sysadmin, scripting, manga and football.

  • 5 Posts
  • 167 Comments
Joined 3 years ago
cake
Cake day: June 13th, 2023

help-circle
  • Yes I do. I cooked a small python script that runs at the end of every daily backup

    import subprocess
    import json
    import os
    
    # Output directory
    OUTPUT_DIR = "/data/dockerimages"
    try:
            os.mkdir(OUTPUT_DIR)
    except:
            pass
    
    # Grab all the docker images. Each line a json string defining the image
    imagenes = subprocess.Popen(["docker", "images", "--format", "json"], stdout = subprocess.PIPE, stderr = subprocess.DEVNULL).communicate()[0].decode().split("\n")
    
    for imagen in imagenes[:-1]:
            datos = json.loads(imagen)
            # ID of the image to save
            imageid = datos["ID"]
            # Compose the output name like this
            # ghcr.io-immich-app-immich-machine-learning:release:2026-01-28:3c42f025fb7c.tar
            outputname = f"{datos["Repository"]}:{datos["Tag"]}:{datos["CreatedAt"].split(" ")[0]}:{imageid}.tar".replace("/", "-")
            # If the file already exists just skip it
            if not os.path.isfile(f"{OUTPUT_DIR}/{outputname}"):
                    print(f"Saving {outputname}...")
                    subprocess.run(["docker", "save", imageid, "-o", f"{OUTPUT_DIR}/{outputname}"])
            else:
                    print(f"Already exists {outputname}")
    






















  • I tried it in the past and it felt too heavy for my use case. Also for some reason the sidebar menu doesn’t show all the items at all times but instead keeps only showing the ones related to the branch you just went into.

    Also it seems pretty dead updates wise

    Mdbook is really nice if you mind the lack of dyanimic editing in a web browser