[SCRIPT] Save Porteus changes made in definied time period

Post tutorials, HOWTO's and other useful resources here.
Post Reply
User avatar
fanthom
Site Admin
Site Admin
Posts: 4626
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
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: 5659
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

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: 1118
Joined: 09 Jan 2011, 18:48
Distribution: Porteus v3.2.5-kde5-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