[SCRIPT] Save Porteus changes made in definied time period

Post tutorials, HOWTO's and other useful resources here.
User avatar
fanthom
Moderator Team
Moderator Team
Posts: 5666
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland
Contact:

[SCRIPT] Save Porteus changes made in definied time period

Post#1 by fanthom » 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"
save it as '/usr/bin/changes-saver' or whatever, and make executable: 'chmod +x /usr/bin/changes-saver'
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
so in next run /opt folder wont be copied to the final destination.

Regards,
fanthom
Please add [Solved] to your thread title if the solution was found.

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: [SCRIPT] Save Porteus changes made in definied time peri

Post#2 by brokenman » 08 Jan 2011, 09:09

Be sure to grab this script. It is probably the most useful script i have seen for assemblers/developers !!

As usual ... excellent job fanthom.
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
wread
Module Guard
Module Guard
Posts: 1255
Joined: 09 Jan 2011, 18:48
Distribution: Porteus v5.0-kde-64 bits
Location: Santo Domingo
Contact:

Re: [SCRIPT] Save Porteus changes made in definied time peri

Post#3 by wread » 19 Jan 2011, 13:20

Fine bussines, fanthom, I was breaking my head trying to find the way to avoid the snow-ball effect that implies creating one module over the others already installed!

Thank you very much!!!
Porteus is proud of the FASTEST KDE ever made.....(take akonadi, nepomuk and soprano out and you will have a decent OS).
The Porteus Community never sleeps!

Post Reply