Wednesday 19 September 2012

Getting the UUID of a drive

From /etc/fstab:


# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).

Tuesday 18 September 2012

archive with daily/weekly/monthly rotation

bin/dailyArchive


# Daily archive script.  There will be scripts for weekly and monthly too.
# Get the day name

today=`date +%A`

# Create todays snapshot archive.
for i in tex py ipynb DAT geo; do
   # create, verbose, bzip2, filename follows:
   find /home/me -name '*.$i' | tar cjvf /mnt/arc/$today$i.tar.bz2 --files-from - > /mnt/arc/$today.log;
   done

bin/weeklyArchive:
# Get the week number

today=`date +%A`
weekNumber=`date +%V`

# Tar todays snapshot archives into an archive
# called this week number.  Call this after the
# weekly archive has completed.

tar xvf /mnt/arc/$weeknumber.tar /mnt/arc/$today* > /mnt/arc/week$weekNumber$today.log

bin/monthlyArchive:
# Monthly archive script.  There will be scripts for daily and weekly too.
# Get the week number

today=`date +%A`
weekNumber=`date +%V`
monthName=`date +%B`

# Tar todays snapshot archives into an archive
# called this month name.  Call this after the
# weekly archive has completed.

tar xvf /mnt/arc/$monthName.tar /mnt/arc/$today* > /mnt/arc/$monthName.log
Do, $ crontab -e and update to,
# minute hour dateOfMonth Month dayOfWeek command # Every night, at 01:01, run the archiver: 01 01 * * * /home/me/bin/dailyArchive # Every Saturday at 17:01, run the weekly archiver. 01 17 * * 6 /home/me/bin/weeklyArchive # Every 1st day of the month, at 07:01, run the monthly archiver. 01 07 01 * * /home/me/bin/monthlyArchive

find all files that have changed in the last seven days


find $HOME -mtime 7 -exec ls -l {} \;

Thursday 13 September 2012

rsync to readynas


export RSYNC_PASSWORD="password"
rsync -avzxr --progress localfiles rsync://username@192.168.1.1:/sharedFoldername/

mount using nfs:  (network file system, the linux standard)

sudo mount 192.168.1.1:/data /mnt/nas

This required,

sudo apt-get install nfs-common

on the machine attempting to connect to the nas.