Docker-Compose Cheatsheet
# Restart single instance and refresh image sudo docker-compose up -d --build backend
# Restart single instance and refresh image sudo docker-compose up -d --build backend
This is an example of doing a quick and dirty restore of a database. Typically happens after doing something stupid, like running UPDATE without a WHERE (oops). In this case, we restore database iix-notes (which by pure coincidence is the same name as this site) from a daily backup. The database is hosted on a postgresql docker container, but it should work the same regardless. Fetch a backup and copy it to the docker container cd $HOME gpg -o iix-notes.daily.psql.gz -d /media/backup/hot/iix-notes.daily.psql.gz.gpg gunzip iix-notes.daily.psql.gz sudo docker cp iix-notes.daily.psql iixnotescompose_database_1:/tmp rm iix-notes.daily.psql Logon to the container, drop the old database, and load it from the backup sudo docker exec -it iixnotescompose_database_1 bash dropdb -U postgres iix-notes psql -U postgres -f /tmp/iix-notes.sql
Backing up stuff to the cloud is all the rage, and I wanted to give it a try. Since I don’t really want to spend any money on it, I decided to go with the best free provider I could find. I haven’t done too much research, but MEGA’s 50 free GB seems to be the best offer around. They also have a simple CLI tool called megatools (manual). Since I couldn’t find megatools in the official debian repo, I decided to use it from docker. There is no official docker container either, so I just grabbed one at the top (tomzo/megatools-docker). He has added two scripts of his own, which may be helpful if you want to see how megatools work (github), but I feel they are too clunky to use. ...
I’ve been looking to buy some kind of external storage for a while now, and this page is pretty much my scratch-page for collecting data. Requirements: Hardware (requirements) Space for 4-6 3.5" HDDs Quiet enough to be unnoticeable from a few meters away Should be around the same size as the hard drives put together (with some space in between of course) Gigabit ethernet Hardware (nice to have) Possibility of mounting 2.5" disks Fans should be still when the drive is not in use Some high-speed connection, like eSATA or USB3, which can be connected directly to another computer Software (requirements), if I can simply install linux on the machine, then the features below are not required RAID 10 Samba Logging/status (CPU, Memory, Storage, Temperature) Access restriction on a user level + anonymous access Software (nice to have) RAID 6 Wake-on-Lan Alternatives to investigate: NAS Servers @ prisjakt Uses its own OS, which usually includes a lot of services Usually needs to flash the ROM to change OS Price range is 1.5-10k SEK External Storage Chassi @ prisjakt No OS, just connected to another machine Price range is 1-4k SEK ZyXEL NAS540/NAS542 Type: NAS Price: ...
# m h dom mon dow command # SQL Backup (daily) 15 1 * * * docker exec -t iixnotes_database_1 pg_dumpall -U postgres | gzip > /media/stor/backup/iix-notes.daily.psql.gz # SQL Backup (weekly) 15 1 * * 0 docker exec -t iixnotes_database_1 pg_dumpall -U postgres | gzip > /media/stor/backup/iix-notes.weekly.psql.gz # SQL Backup (monthly) 15 1 1 * * docker exec -t iixnotes_database_1 pg_dumpall -U postgres | gzip > /media/stor/backup/iix-notes.monthly.psql.gz
server { listen *:80; server_name _; return 301 https://$host$request_uri; }
server { listen *:443; server_name iix.se; ssl on; ssl_certificate /etc/letsencrypt/live/iix.se/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/iix.se/privkey.pem; ssl_session_cache builtin:1000 shared:SSL:10m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4; ssl_prefer_server_ciphers on; location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://127.0.0.1; proxy_read_timeout 90; } }
Description=iix-notes @ iix.se docker Requires=docker.service After=docker.service [Service] WorkingDirectory=/srv/iix-notes ExecStart=/usr/local/bin/docker-compose up ExecStop=/usr/local/bin/docker-compose down [Install] WantedBy=multi-user.target
# /etc/systemd/system/spark-backend.service Description=iix.se java spark backend After=network.target [Service] WorkingDirectory=/srv/spark-backend User=www-data Group=www-data ExecStart=/srv/spark-backend/bin/spark-backend [Install] WantedBy=multi-user.target
Crontab for renewal # m h dom mon dow command 15 3 * * * certbot renew --quiet --no-self-upgrade --pre-hook "systemctl stop nginx.service" --post-hook "systemctl start nginx.service" Docker alternative Note that if you run certbot in docker, you cannot use the –pre-hook and –post-hook as the other services cannot be changed through the docker container. Instead, you should create a script file, where you run the –pre-hook before the command and –post-hook afterwards ...