Incessant tinkerer since the 70’s. Staunch privacy advocate. SelfHoster. Musician of mediocre talent. https://soundcloud.com/hood-poet-608190196

  • 25 Posts
  • 807 Comments
Joined 10 months ago
cake
Cake day: March 24th, 2025

help-circle

  • My docker files, configs, and volumes are all kept in a structure like:

    Over the years, I have gravitated to keeping docker compose, configs, et al, in structured directories in lieu of docker just splattering the HDD willie-nilly, with configs anywhere and everywhere. It sure makes problem solving much easier when you can go directly to where each component is instead of spending 30 minutes trying to locate where docker put everything.


  • Out of curiosity, how are you doing the drive imaging?

    I wrote a script that is fired by a cron job once a month:

    sudo nano /usr/local/bin/backup_drive.sh

    spoiler
    # Directory to store backups
    
    BACKUP_DIR="/mnt/myhdd"
    
    # Drive to backup
    
    DRIVE="/dev/sdX"
    
    # Create a timestamp
    
    TIMESTAMP=$(date +"%Y%m%d")
    
    # Filename for the new image
    
    NEW_IMAGE="$BACKUP_DIR/my_drive_image_$TIMESTAMP.img"
    
    # Create the image
    
    sudo dd if=$DRIVE of=$NEW_IMAGE bs=4M status=progress
    
    # Keep the last 3 images
    
    ls -tp $BACKUP_DIR/my_drive_image_*.img | grep -v '/$' | tail -n +4 | xargs -I {} rm -- {}
    

    Make the script executable:

    sudo chmod +x /usr/local/bin/backup_drive.sh

    Create Cron:

    sudo crontab -e

    0 3 1 * * /usr/local/bin/backup_drive.sh

    Verify cron:

    sudo crontab -l

    I’m sure it could be written differently or that there is a better way to do the imaging, but that is the extent of my notes, and it works for me. As with any code you find on the internet, it is wise to evaluate before dropping on a production server.







  • irmadlad@lemmy.worldtoSelfhosted@lemmy.worldWhere to start with backups?
    link
    fedilink
    English
    arrow-up
    3
    arrow-down
    1
    ·
    2 days ago

    In addition to daily backups, once a month I image the drive. I wrote a simple script triggered by a cron job to image the drive to a NAS backup. The daily backups go to 3 different offsite storage facilities, and two go to separate NAS drives. All drive images are kept both local and off premise as well. So, for individual files, etc, I can restore them from the daily backups. If the wheels fall off, I can restore the whole drive from an image. Might be a bit over engineered but I’ve been caught a few times and so I just decided that won’t happen again.