Stuff
Friday, 1st October, 2010
Booklet Printing
Why is this so hard to do manually‽ Getting the pages the right way up, around, size etc. makes my head hurt… As a result, I’ve modified the very excellent script from Maemst to work a little better with my printer. The main changes are increased margin for the left even page and to line the pages up more accurately (0.5cm added to the even pages bottom margin.)
#!/bin/bash
#
# call with dina5_book file.pdf
file=$1
filebase=$(basename $file .pdf)
pdftops $file output.ps
psbook output.ps tmp.ps
pstops "4:0L@.65(21cm,0)+1L@.65(21cm,14.85cm),2R@.65(0.5cm,27.8cm)+3R@.65(0.5cm,14.85cm)" tmp.ps > ${filebase}-booklet.ps
rm -f output.ps tmp.ps
echo "Converting back to pdf ..."
ps2pdf ${filebase}-booklet.ps
rm -f ${filebase}-booklet.ps
Note: When printing select “odd pages only” for the first run. On my printer the paper comes out with content face down and the top on the left, so I have to flip the pages over, now the odd pages are facing up with the top of the pages to the right. I then put the paper back in the main tray, and print the even pages. Finally I need to reverse the order, so the page at the top of my pile becomes the bottom, etc. (I’ve not had any success reversing the original print order,) then fold into a booket.
Incremental Backup
This script does a daily backup from ~/Documents to an external drive, /media/backup. It uses hard links to minimise storage and rsync to do the copying and syncing of the files. After a week you end up with Documents-Monday’s-date, Documents-Tuesday’s-date, etc. but it only takes up the storage of one copy plus any changed files. At the end of the week it “recycles” the days, rsync does a good job of keeping the files matching the original, and it saves doing more copies than is needed, good for flash based drives. It was inspired by the Easy Automated Snapshot-Style Backups with Linux and Rsync, but I wanted something more intuitive than just backup numbers, dates help me have a better idea of when the backup was created, rather than just that it exists. The best way to use this file is to plonk it into /etc/cron.daily/ so it runs every day, just save the code into a file there and you’re away. So long as you have cron running!
#!/bin/bash
# Incremental daily backup system using rsync and hardlinks by Christopher Joice.
# http://chrisjoice.co.uk
#First we need to know dates for Today, Yesterday and a Week ago.
today=`date "+%F"`
yesterday=`date --date='1 day ago' "+%F"`
aweekago=`date --date='7 days ago' "+%F"` #change 7 to how many days of backup you want to keep
#empty last week's backup
rm -r /media/backup/Document-$aweekago/
#hardlink copy yesterday's folder, into today's
cp -al /media/backup/Documents-$yesterday/. /media/backup/Documents-$today
#update today's folder with any changes, deleting any files that are no longer on the master
rsync -a --delete /home/christopher/Documents/ /media/backup/Documents-$today