ffmpeg, grep and find, oggenc

shows if music file is specified type with ffmpeg.

ffmpeg -i abba/the_complete_singles_collection_cd1/abba-_knowing_me_knowing_you.ogg  
2>&1  /dev/null | grep "Audio: mp3, 44100 Hz, 2 channels, s16, 128 kb/s" | wc -l

converts defekt oggs to good ones that are modified > 24 hours ago.

find /data/files/music/ -mtime +1 -name *.ogg -exec pacpl --overwrite -r -t ogg -o ogg {} ;

sms sending with bash text input and multipe numbers in vcard (.vcf) file

#!/bin/bash

#$1=Nachrichtentext
#$2=vcf Datei

if [[ $1 && $2 ]]
then
numbers=`sed ’s/.$//’ $2 | grep -E ‘TEL;PREF:[0-9]{10}|TEL;PREF:+[0-9]{10}’ | cut -c10- | xargs`
for number in $numbers
do
echo $1 | gnokii –sendsms $number
#sleep 1
done
else
echo “Message or vcf is/are null. Aborting.”
exit 1
fi

backup script with mgzip,tar,xfsdump and incremental function

#!/bin/sh

# Compressed dumps may be restored with “gunzip -c xfsdump.gz | xfsrestore -i – /restore/path”

# Usage:
# ./backup.sh [dump_level]
# With no arguments, the script will backup filesystems using incremental dump options (-l)
# The dump level is the offset from the first day of the week, ie: Sunday = 0, Monday = 1, etc..
# If dump_level is specified, then this will override the default behaviour.

# Example:
# An example cron job entry, to run at 4am every day.
# 0 4 * * * * /root/scripts/backup.sh

# commands
WALL=”/usr/bin/wall”
XFSDUMP=”/usr/sbin/xfsdump”
MOUNT=”/bin/mount”
UMOUNT=”/bin/umount”

# variables
BACKUP_PATH=”/backup/gw” # could be subdir of mount path
MOUNT_PATH=”/lvm-snapshot/root/”
MEDIA_LABEL=”Backup Drive (data)”

# it all starts here
main() {
# Perform pre backup operations
pre_backup

# Get the level of the backup (can be overriden with argv[1])
if [ “$1” != “” ] ; then
echo “Overriding dump level with $1”
LEVEL=$1
else
LEVEL=`date +%w`
fi

# Perform the backups
# These commands could be rolled into a separate function, but I
# decided against this to improve readability.

# backup /data/diskless
if [ “$LEVEL” == “0” ] ; then
$XFSDUMP -F – /data | mgzip > “$BACKUP_PATH/data_xfsdump$LEVEL.gz”
else
$XFSDUMP -F -l $LEVEL – /data | mgzip > “$BACKUP_PATH/data_xfsdump$LEVEL.gz”
fi
# backup /
if [ “$LEVEL” == “0” ] ; then
rm -rf $BACKUP_PATH/root.snar
fi
tar -g $BACKUP_PATH/root.snar -cvf – $MOUNT_PATH | mgzip > $BACKUP_PATH/root_tardump$LEVEL.gz
# backup /boot
if [ “$LEVEL” == “0” ] ; then
rm -rf $BACKUP_PATH/boot.snar
fi
tar -g $BACKUP_PATH/boot.snar -cvf – /boot | mgzip > $BACKUP_PATH/boot_tardump$LEVEL.gz

# Perform post backup operations
post_backup
}

# commands to perform before the backup occurs
pre_backup() {
# warn users of backup
`echo Daily backups are being performed. You may stay logged in while this occurs. | $WALL`

# set the umask
umask 027

# mount the backup volume
echo “Creating LVM lv.”
lvcreate -L1G -s /dev/main/root -n root_backup
echo “Mounting $MOUNT_PATH”
if ! `$MOUNT /dev/main/root_backup $MOUNT_PATH -o ro -t ext4`; then
echo “Unable to mount $MOUNT_PATH (perhaps its already #mounted?)”
exit 1
fi
}

# commands to perform after the backup occurs
post_backup() {

# unmount the backup volume
echo “Unmounting $MOUNT_PATH”
if ! `$UMOUNT $MOUNT_PATH`; then
echo “Unable to umount $MOUNT_PATH”
exit 1
fi
echo “Removing LVM lv.”
lvremove -f /dev/main/root_backup

# notify users that backup is complete
if [ $? == 0 ]; then
`echo Backups completed. | $WALL`
else
`echo Backups ERROR. Something got wrong. | $WALL`
fi

}

# do main
main $@

dd progress

Run normal dd normal like:

/bin/dd if=gw-1.iso of=/dev/sr0

For progress open a new terminal on the host and run:

killall -USR1 dd

dd’s working and it puts you info to the terminal.

e.g.:

353049+0 Datensätze ein
353049+0 Datensätze aus
180761088 Bytes (181 MB) kopiert, 254,912 s, 709 kB/s

some script snippets:


#!/bin/sh

dd if=$1 of=$2 &
while [ !  $(ps -p $! > /dev/null ) ]; do kill -USR1 $! ; sleep 1; done
exit 0