A chronological documentation test project, nothing serious, really!

24 Sep 2012 Rotate and rename images according to their EXIF info

This is my short script to rotate and rename image files accoring to date captured based on their EXIF info.
You need jhead and exiv2 to run this. These two programs are also available in Windows and only require you to make small changes to work there as well.

#!/bin/bash -x
echo Rotating JPEG file(s)
jhead -ft -autorot D*.JPG

echo Rename(ing) file(s)
exiv2 -r '%Y%m%d-%H%M_:basename:' rename $(ls D*)

The files are then named like this (YYYYMMDD-HHDD_OriginalFileName.extension)


This script has been tested on Nikon D80 and D7000 image files.

Tags: , , , , , ,

Posted by

24 Sep 2012 Using rsnapshot as backup solution

This post describes short how to use rsnapshot as a remote filesystem snapshot utility, based on rsync that I use as my personal backup tool.
I have started using rsnapshot after using rsync and rdiff-backup and lost files because of file corruption.
rsnapshot is a great backup utility because it hardlinks files if they already exists and your backups does not take much more space than the actual filesystem you are backing up.
You need to configure passwordless SSH connection from the backup server to the file server if you plan to run this as a automated job using crontab.

This is the content of my config file (/root/scripts/rsnapshot-home.conf) to backup my remote fileserver

config_version  1.2
snapshot_root   /media/Backup/
cmd_cp  /bin/cp
cmd_rm  /bin/rm
cmd_rsync       /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_logger      /usr/bin/logger
cmd_du  /usr/bin/du
interval        daily   7
interval        weekly  4
interval        monthly 3
verbose 2
loglevel        4
logfile /var/log/rsnapshot-home.log
exclude_file    /root/scripts/rsnapshot-home.exclude
rsync_long_args --delete        --numeric-ids   --delete-excluded
lockfile        /var/run/
backup      files/

The config file is tab delimited so you will get errors if you use space instead!

Running manual daily backup can be done with the command

# rsnapshot -c /root/scripts/rsnapshot-home.conf daily

You do now have a folder structure like this with your backups


Where daily.0 is the newest backup.

The backup files are store in the same form as in your file server so you can browse them using a regular file browser.
You can read more about restoring backups on the rsnapshot HOWTO.

You can also configure a report to be sent after every backup with the perl script but I will not be covering that in this post.

Tags: ,

Posted by

20 Sep 2012 VMware Tools one-liners using PowerCli

This short post is about VMware Tools on VM guests running in a vSphere 5.x cluster/hosts.

This PowerCli one-liner creates a list of VM guests where the VMware Tools CDROM/ISO is mounted:

(Get-VM | Get-View | Where {$_.Runtime.ToolsInstallerMounted}) | % {$_.Name}

Unmount the VMware Tools installer CDROM on all VM guests. This is useful to run before you try to put at ESXi host in maintenance mode because VM guests thatare installing VMware Tools will not migrate because the VMware Tools is not on a shared storage. You will get the error message “The virtual machine is installing VMware Tools and cannot initiate a migration operation”.

(Get-VM | Get-View | Where {$_.Runtime.ToolsInstallerMounted}) | % {Dismount-Tools

This last one finds all VM guests running Windows as guest OS and upgrades VMware Tools without a reboot at the end

Get-VM | Where {$_.PowerState -eq "PoweredOn" -and $_.Guest.OSFullName -match "Win*"} | % {Update-Tools -VM $_ -NoReboot}

Tags: , , , , , ,

Posted by