Hey
Ive been asked (and I may add this to my system as well) to make a shell script that backups to all files in x location to another location in z. The thing is that the backup must only be made if one file has been changed. Example:
/x contains:
a (1 byte)
b (1 byte)
c (1 byte)
/y contains:
nothing
Ill put this script into CRON's file and everytime (say 3) it will execute. 3 arrives and there is nothing in /y and it will copy all files in /x to /y. To compensate space I think a good idea (this I will do to my script for my system) is gzip it all up. Anyways the current state right now is.
/x contains:
a (1 byte)
b (1 byte)
c (1 byte)
/y contains:
a (1 byte)
b (1 byte)
c (1 byte)
Again 3 arrives and /y is the same as /x so nothing changes and nothing happens. But now, I open c in /x and type something inside now it is:
/x contains:
a (1 byte)
b (1 byte)
c (2 bytes)
This changes it so now when the script excutes at 3 it has to delete everything in /y and rewrite it all over again (regardless that the other files havent changed).
How do I do this? I imagine something like doing a ls -a on /x and using cut to cut certain columns and seeing if it equals /y's files/file sizes but im not sure how to make a filename and file size relation and a bit humiliating but I dont know how to use cut either (I know something but still)
If someone could help thank you very much.