Compress and encrypt your backups

It’s always recommended to backup your data for safety, but for safety AND security let’s encrypt your backups! to compress and encrypt with ‘mypassword’: tar -Jcf - directory | openssl aes-256-cbc -salt -k mypassword -out backup.tar.xz.aes to decrypt and decompress: openssl aes-256-cbc -d -salt -k mypassword -in backup.tar.xz.aes | tar -xJ -f - Another trick with the tar command is useful for remote backups: tar -zcvfp - /wwwdata | ssh root@remote.server.com "cat > /backup/wwwdata.tar.gz" ...

June 11, 2014 · Andrea Manzini

how to display the IP address of a virtual machine before logon

For testing or development purposes, I do a wide use of small linux virtual machines. After spawning a new guest (Virtualbox, VMWare or any other), often you want to log on over ssh but you don’t yet know its ip address. You need to login as ‘root’ in the console just to issue a quick ‘ifconfig’, and after writing down the address, you logout and connect with your comfortable terminal. In order to save some time and keystrokes, I put this in my rc.local of all my guest VMs: ...

May 5, 2014 · Andrea Manzini

dovecot: cleaning old Spam and Trash messages after some days

This script is useful to delete old messages in “Junk” mail folders (Spam, Trash) automatically after some days. adapted from these notes to work on debian/postfixadmin/dovecot #!/bin/bash # # itera sulle mailbox cancellando messaggi vecchi # per default, nel cestino 30gg e Spam 15 gg # # MySQL details HOST="127.0.0.1"; USER="put_here_your_mysql_user"; PWD="put_here_your_mysql_password"; MYSQL="/usr/bin/mysql"; # dovecot details DOVEADM="/usr/bin/doveadm"; TEMPFILE=$(/bin/mktemp) # Output sql to a file that we want to run echo "use postfixadmin; select username from mailbox" > $TEMPFILE # Run the query and get the results (adjust the path to mysql) results=$($MYSQL -h $HOST -u $USER -p$PWD -N < $TEMPFILE); # Loop through each row for row in $results do echo "Purging $row Trash and Junk mailbox..." # Purge expired Trash $DOVEADM -v expunge mailbox Trash -u $row savedbefore 30d # Purge expired Spam $DOVEADM -v expunge mailbox Spam -u $row savedbefore 15d done rm $TEMPFILE

March 5, 2014 · Andrea Manzini

number of physical sockets and cpu cores

a small script to check out the number of processors in your linux machine mandatory sample output:

September 14, 2013 · Andrea Manzini