Just a link to remember. If you want to backup your entire partition using dd:
Creating a hard drive backup directly to another hard drive
Also, very useful boot cd with live linux and utility partimage: System rescue CD
I have data recieved from ftp, which is encoded using GnuPG software.
To get files nightly, I used cron task scheduler. But there were problem when decoding gpg files (when ran shell script, everything went ok, but when cron initialised, no decryption were done).
This is a shell script:
for i in `find $gpgdir -name ‘*.gpg’ -type f -maxdepth 1` ; do
echo ‘thepassword’ | /usr&/bin&/gpg passphrase-fd 0 -o ${i%.*} -d $i
done
As you can see, script finds all *.gpg files in given directory, then passes file by file to gpg to decode files.
But it does not work when executed with cron.
After some debugging, found such error:
So, gpg tries to open tty, but in cron enviroment there is no access to tty. So found out switch to gpg no-tty.
This is the final, working excerpt from my script:
for i in `find $gpgdir -name ‘*.gpg’ -type f -maxdepth 1` ; do
echo ‘thepassword’ | /usr/bin/gpg no-tty passphrase-fd 0 -o ${i%.*} -d $i
done
P.S. Echoeing password through pipe to give it as parameter to gpg is not secure, if your server is accesed by other users. At good timing, user can get your password. As my server accessed only in trusted LAN, and no other users use shell, I’ve made that method.
If you are using linux crontab to automate some processes, allways use full path to scripts or other executable files.
Recently, I was writing one bash script, which uses munpackutility. Tested it – worked with no problems. After adding script to crontab, to do this routine daily, I’ve noticed, that something is wrong.
Problem was, that munpack was in /usr/local/bin/bin/munpack directory, and there was created symlink /usr/local/bin/munpack.
So, crontab didn’t follow symlink.
Recently I was writing Bash shell script, which moves files and directories from one server to other. As files and folders are created by end users, there are problems about file names.
Users create folders with spaces e.g. very important and Bash script interprets it as two separate folders: very and important when my script finds all folders and starts to move them, I get error on folders with spaces. This is the command:
This piece of code moves files and folders older than 14 days from /mnt/volume/tomove to /path/tomovewhere
So, if there is folder /mnt/volume/tomove/very important
Bash tries to move /mnt/volume/tomove/very and important
To interpret directories as one command you will need to add this variable to your script:
$IFS is internal field separator, this variable determines how Bash recognizes fields, or word boundaries, when it interprets character strings.
You can find more info with samples here:
http://tldp.org/LDP/abs/html/internalvariables.html
