Save work

Non release banter
User avatar
dreadbird
Samurai
Samurai
Posts: 169
Joined: 08 Dec 2024, 04:30
Distribution: porteus5

Save work

Post#1 by dreadbird » 09 Jan 2025, 03:46

Found this from years back in porteus forum and made it into a module by Joe Arose bigbass
applied to always fresh and changes=EXIT


savework module
https://drive.google.com/file/d/13_3RF6 ... sp=sharing


go to porteus settings manager and paste (for startup commands rc.local) :

touch /home/guest/start_count.txt
touch /tmp/list_recent.txt


What this does is on system bootup it makes a file for a time stamp.

When savecurrent is called It finds all files newer than that file (your changes) only in /home/guest/

it compresses it to a module and leaves it in /home/guest/ though you probably should move it to another drive (wont be saved)


Included is a symbolic link you can type savecurrent and it will execute this script or you can go to /home/guest to execute.


Why is this beneficial? thats where all your desktop changes and important work is. so if you run this script you will have a module of only those exact changes made to your desktop webbrowser configuration basically any settings ect. it doesnt effect anything its just a copy.

Its a backup. lets say your playing around with your system and you know you shouldnt save your changes because you might mess it up. execute this script you have all your work excluding any system changes. So you have this module to save all your work. reboot and activate the module to have your settings back that you changed last session.
Last edited by dreadbird on 09 Jan 2025, 19:35, edited 6 times in total.

User avatar
dreadbird
Samurai
Samurai
Posts: 169
Joined: 08 Dec 2024, 04:30
Distribution: porteus5

Save work

Post#2 by dreadbird » 09 Jan 2025, 04:12

Always fresh or changes=EXIT

here is another one you can play around with (pulled off forum as well)

These are backup tools which have endless possibilities to be used
Generalized script to show how different options can be used

#!/bin/sh

# folders to check (tweak for your needs):
folders="/etc /home /root /opt /usr /var"

# gather all files in one place:
mkdir /tmp/backup_folder
find $folders | xargs -I {} cp -a --parents {} /tmp/backup_folder

#create the module on your desktop with current date:
dir2xzm /tmp/backup_folder $HOME/Desktop/changes-`date +"%m-%d-%y"`.xzm
rm -r /tmp/backup_folder


For instance you may want to use this is you have your system exactly how you like it. It creates a backup move it to your other drive. Dont need to use timeshift or anything else in the event you lose your changes folder.


How can we modify this to suit our needs?

cd /mnt/live/memory/changes/
find $folders | xargs -I {} cp -a --parents {} /tmp/backup_folder

dir2xzm /tmp/backup_folder /mnt/sda3/mybackup/changes-`date +"%m-%d-%y"`.xzm
rm -r /tmp/backup_folder


that should make a backup of your changes and labeled. so you have an archive of what was saved and when.
configure it to match what changes-commit uses. so its somewhat of an archive what has been put on your system.

over write a file today or a week ago? or messed up your install somehow. have it in one of the archive files. kind of a neat tool

Vic
Samurai
Samurai
Posts: 163
Joined: 10 Aug 2016, 05:36
Distribution: Porteux V-0.1 64 KDE
Location: Utopia in Tampa, Florida, USA

Save work

Post#3 by Vic » 10 Jan 2025, 02:20

Hey dreadbird

I use two scripts:

Code: Select all

#! /bin/bash

touch /root/start_count.txt
touch /tmp/list_recent.txt
and make changes to specific items, then run

Code: Select all

#! /bin/bash

cd /root/
konsole --noclose -e find -newer  start_count.txt |tee  /tmp/list_recent.txt &
rm /tmp/list_recent.txt
which then shows the changed files in Konsole.

Since there are always more files than I want I just use the list to pick out the relevant ones.
It makes the resulting module much more specific and usually smaller too.

Thanks for posting,

Vic

User avatar
dreadbird
Samurai
Samurai
Posts: 169
Joined: 08 Dec 2024, 04:30
Distribution: porteus5

Save work

Post#4 by dreadbird » 10 Jan 2025, 14:09

Yeah that would be helpful. gives you an idea of what is effected and even what directories you should omit if there are too many files ect.

I find these scripts more helpful than htop or conky. I like to know already in memory whats happening and not installing unnecessary apps (bloat).

User avatar
dreadbird
Samurai
Samurai
Posts: 169
Joined: 08 Dec 2024, 04:30
Distribution: porteus5

Save work

Post#5 by dreadbird » 17 Jan 2025, 01:36

Here are the scripts. extract files to /home/guest/

https://drive.google.com/file/d/16J9iKG ... sp=sharing

contents
/home/guest/recentfiles
/home/guest/savecurrent
/home/guest/startcount


edit /etc/rc.d/rc.local (so when system boots there is a reference point to search for new files)

touch /home/guest/start_count.txt
touch /tmp/list_recent.txt


savecurrent will save all changes in /home/guest/ since last update of start_count.txt to a module
dated and left in /home/guest/

if you want to start a new reference point run startcount script to create a new start_count.txt file (update time).


I also included recentfiles script. that goes to / directory as root. searches the entire contents of drive

it will search these directories (default changes-exit.conf setup)
/bin /etc /home /lib /lib64 /opt /root /sbin /usr /var

it will display a summary of files (what you can see on the screen) and saves the full list in /tmp/

go to /tmp/list_recent.txt for the full list of new files.


How is this useful?

If youre building or compiling an app you can use recentfiles to see exactly where each file was installed and pull them to make a module. Or you may have accidently moved a file somewhere and this can find it. Gives you an idea of what changed on the system. So before doing some changes you can run startcount script to set the time. Make the changes and then run recentfiles to see what changed.

Theses scripts came from this forum so I just updated them and tweaked to different scenarios. Joe Arose bigbass, vic and others making the original scripts.

quick and dirty to find files (run as su)

Code: Select all

find /bin /etc /home /lib /lib64 /opt /root /sbin /usr /var -type d \( -path /home/guest/.cache -o -path /root/.cache \) -prune -o -mmin -15 -not -type d -print 
this will exclude the cache directories in the search.

vinnie
Samurai
Samurai
Posts: 191
Joined: 13 Jun 2024, 08:25
Distribution: alpine

Save work

Post#6 by vinnie » 09 Feb 2025, 09:49

Ok, I want to give my contribution.

I have downloaded and read your script although I have not tried it yet, I have some things to say.

1) I saw that you search inside the system, but it is my understanding that porteus by default already puts all the files changed since the last run in “/mnt/live/memory/changes” which is used by the “/usr/local/sbin/changes-time” script and this way the search is BLAZING fast.
The only con is that it should not check on real physical partitions, but really it seems to me just a feature and not a con.
If I understand correctly, your script searches only in the current directory?

2) I saw that you put your scripts in "/home/guest" and then linked them in "/usr/bin".
Even though I think you did it to make the scripts editable by the user, I think it's not a very good idea because you can't be sure that the default "guest" user hasn't been changed.
Maybe it would be better to put it in "/usr/local/sbin" like the "changes-time" script, then maybe you can give everyone permission to edit the script.

3) I rediscovered my old saves script (which I consider worse than changes-time from porteus) and saw, however, that perhaps there is something in it that might be useful, so I am sharing it (sorry for the Italian, I didn't mean to share it when I wrote it).
However approximately two things are conceptually different.
The first is that I concentrate everything in one file and then at startup I ask if you want to generate your new marker, if yes is answered, it generate the mark and close the script, if no is answered then I ask if you want to search for the changed files.
The second thing is that instead of filtering the directories after doing the search, I do it first with the idea that this way the search should be faster preventing find from navigating inside excluded directories.
I tried running it, it works although it gave me an error it shouldn't have given me (find: '/run/user/1000/gvfs': Permission denied because in theory the dir /run was removed from the search and find does not search inside it) so there is some problem.
However, it might not be your intent since it seems to me that your script only searches in the current directory.
And likewise porteus script is much faster than mine, although it should not show changes if for example you are modifying files on a real partition

Code: Select all

#!/bin/sh

#HELP
help="\
Cerca tutti i cambiamenti nel sistema escludendo le dir dove non bisogna cercare
Script ancora non elaborato, non si puo' parametrizzare.
Si usa cosi:
1) Si avvia una volta e si risponde y, viene creato il marcatore temporale
2) Si fanno i cambiamenti al sistema
3) Si riavvia lo script e non si risponde y, i cambiamenti vengono mostrati e salvati in /tmp/changes
"
for i in "${@}"; do
	if [ "${i}" = "--help" ] || [ "${i}" = "-h" ]; then
		echo "${help}"
		return 0
	fi
done


#UNISCE LE DIR (unisce gli argomenti con un solo /, non mette niente all'inizio)
join_paths() {
    (IFS=/; echo "$*" | tr -s /)
}

#~ find /bin/ /dev/ /etc/ /home/ /lib/ /opt/ /root/ /run/ /sbin/ /srv/ /sys/ /usr/ /var/ -newer /tmp/mark > ./list

#CREO IL MARCATORE
tmpmrk='/tmp/mrk'
read -p "Inizializzare marcatore temporale? [y/n]: " risposta
if [ "${risposta}" = 'y' ]; then
	if [ -f "${tmpmrk}" ]; then
		read -p "Il marcatore gia' esiste, continuare? [y/n]: " risposta
		! [ "${risposta}" = 'y' ] && return 0
	fi
	touch "${tmpmrk}"
	echo "Fai i tuoi cambiamenti al sistema!"
	exit #return 0
fi


strdir='/'
#dir escluse a partire dalla dir iniziae e che contengono la parola specificata
direct='dev media mnt proc run sys tmp var'
alldir='mozilla gomuks'
#~ pattrn='-not \( -path "#PURGEDIR" -prune \) \\'
pattrn='-not \( -path "#PURGEDIR" -prune \)'
cmdarg=''
sostit=''
for dir in $direct; do
	dir=$(join_paths "${strdir}" "${dir}*")
	sostit="${pattrn//#PURGEDIR/$dir}"
	cmdarg="$cmdarg $sostit"
done

for dir in $alldir; do
	dir="*${dir}*"
	sostit="${pattrn//#PURGEDIR/$dir}"
	cmdarg="$cmdarg $sostit"
done


commnd="find \"${strdir}\" -newer ${tmpmrk} ${cmdarg}"
su root -c 'eval "${0}"' "${commnd}"  

User avatar
Ed_P
Contributor
Contributor
Posts: 8812
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Save work

Post#7 by Ed_P » 09 Feb 2025, 19:00

vinnie wrote:
09 Feb 2025, 09:49
it is my understanding that porteus by default already puts all the files changed since the last run in “/mnt/live/memory/changes”
:good: Yup :happy62: and that's what makes Porteus unique :punk: and modular. :celebrate3:

vinnie
Samurai
Samurai
Posts: 191
Joined: 13 Jun 2024, 08:25
Distribution: alpine

Save work

Post#8 by vinnie » 10 Feb 2025, 00:24

:Bravo: :punk: :Yahoo!: :thumbsup:

User avatar
dreadbird
Samurai
Samurai
Posts: 169
Joined: 08 Dec 2024, 04:30
Distribution: porteus5

Save work

Post#9 by dreadbird » 12 Feb 2025, 02:57

Changes:EXIT xzm (Post by dreadbird #102029)

i combined the scripts and different methods into this module. the idea is that it works for changes:EXIT and also regular saving. so if you type recentchanges search 1800 it will give you all files half an hour. type it again it will give you a new list and also a difference list. ie only the 7 files new since you typed it 3 minutes ago. it proved to be quiet effective and the log gives you times of each file. i put a bunch of features into it and the idea was simplicity. so if you type recentchanges search it defaults to 5 minutes.

you can also recentchanges search /home/guest/myfile and it will use the filter and show only files you care about ie new files not .cache or xauth ect. i do quite a bit of compiling and sometimes i have no idea where files ended up. you can just type recentchanges 9 and it will grab all files 9 seconds old package it log it and also give you the entire system log of 9 seconds. then it will latch onto the previous search if you type it again ect. and show the differences. still tweaking it and finally got it to 1.0 release and it works pretty good so far

the user is passed so if your user dave it will work with home/dave. the custom filter building with the compile mode will interpolate the difference before and after and alert you that there was a difference. the customfilter profile has all files that made it past the filter and generate custom sed statements to drop into recentchanges. So what it does is take all files before and all files after is there a difference? then appends the files after to the files before to give you a total. ie you want to see all the system files and also all the filtered files that made it past the filter. so if there is a difference the program will alert you.

you get system seds if you want to pick one out of there and the custom profile which is the files that made it through the filter pass with seds for that. then take those and put in recentchanges to calibrate the filter for your system. and it will generate custom instructions in /user/dave/.config/save-changesnew

Post Reply