[SCRIPT] Save Porteus changes made in definied time period
Posted: 08 Jan 2011, 08:13
Code: Select all
#!/bin/bash
clear
#variables
changes=/mnt/live/memory/changes
tmp=/tmp/work$$
path=/root/changes$$
echo "enter time interval or press enter for keeping default value (3 minutes):"
read int
if [ ! $int = "" ]; then
time=$int
else
time=3
fi
#creating tmp dir
mkdir $tmp
#locating and copying newly created/modified files
file=`find $changes -mmin -$time`
for x in $file; do
cp -P --parents $x $tmp 2> /dev/null
done
#we dont want to store /root and /tmp folders (you can add or remove paths which will be excluded from saving)
rm -r $tmp/$changes/root /$tmp/$changes/tmp
#moving all stuff to final destination
mv $tmp/$changes $path
echo "all files created/modified in last $time minutes were copied to $path folder"
if you want to remove some dirs other than /root and /tmp - add them to proper place in the script. EXAMPLE:
Code: Select all
rm -r $tmp/$changes/root /$tmp/$changes/tmp /$tmp/$changes/opt
Regards,
fanthom