JRehkemper.de

JRehkemper.de

- Homepage and Wiki of Jannik Rehkemper -

New Posts

Restore Crontab From Backup

Restore from Filesystem Backup If you deleted your Crontab for example with crontab -r but have full filesystem backup you can restore it by recovering /var/spool/cron/<your-user>. After that you can reload it into your active Crontab by executing crontab </path/to/restored/crontab/file> Restore from Syslog If you don’t have a backup you best chance is to have a look at /var/log/cron. There you will find all the Commands executed and based on the timestamps you can reverse-engineer the cron-expression.

Upsert in PostgreSQL - Update if exists

It is quite a common scenario: You have a table and want to insert a new record, but in case it already exists, you want to update it. One way would be to start with the update, look at the rows affected and execute the insert if the rowCount is 0. But there is a neater way. The so called Upsert. INSERT INTO table1 (id, firstname, lastname, age) VALUES (1, 'john', 'doe', 25) ON CONFLICT(id) DO UPDATE SET id = 1, firstname = 'john', lastname = 'doe', age = 25 ; This will try an insert but if there is already an entry with the same id it will update that one.

Update a Joined Table in PostgreSQL

If you joined two tables and need to update one of them, there are multiple ways to do so. Select Query My Example uses a join to lookup a name to an id. SELECT a.id b.name a.value1 a.value2 FROM tablea a JOIN tableb b ON a.id = b.id; Using Subquery One approach is to use a subquery. UPDATE tablea a SET value1 = 1, value2 = 2 WHERE a.id = (SELECT "id" FROM tableb WHERE "name" = 'John'); Using Joined Update You can also join while doing the update.

Kubernetes Ingress with Custom SSL-Cert for HTTPS

I assume you already have an valid SSL-Certificate and the corresponding key. The SSL connection and certificate will be handled by the ingress-controller. Therefor we do not need to include the SSL-certs into the container images but the manifest instead. That way you can change the certificate without building new images. Create a Secret To reference the Certificate in the manifest we need to provide the certificate and the key to kubernetes.

Add Custom CA SSL Certificates to Docker-Images

If you have a custom CA and want your docker images to trust you certificates, you have to include the ca-certs in you images. This is different depending on the distribution of the base-image. Debian Based For Debian add these lines to your Dockerfile and provide the expected files. FROM debian ADD certs/my-cert.cer /usr/local/share/ca-certificates/my-cert.crt RUN chmod 644 /usr/local/share/ca-certificates/* RUN update-ca-certificates ... It is important that your cert needs to have the filetype .