Hello All,
My resources:
1)Linux OS 7 (execution via terminal)
Question :
folders & files copy both copy from one X FS path to Y FS path
Note : if same name file created next day then not overwrite original file in Y FS
scenario:
X file system path
/opt/x/jboss/jvm/log/{any type log}
/opt/x/tomcat/logs/{any type log}
Y file system path
/archive/y/jboss/jvm{any type log}
/archive/y/tomcat/logs/{any type log}
-----------------
copy folders & files from X path FS to Y path FS ( while copy from X path if any newly folder creates then copy newly created folder with file from X path to Y path ) .
Requirement is copy folder already exists ( not overwrite) & file (not overwrite but if same name already exists comes from X FS path then keep old as backup then copy new file in Y FS path)
Note : condition
copy only 24 hours generated files as per folder
Please provide me if any comand or script for above mentioned criteria .
Please provide your valuable suggestions & guidance .
I am waiting for your valuable information.
Regards,
Jeesshnasree
Hello @jeesshnasree !
Thanks for reaching out !
Getting a pre-configured shell script or command from others here will not help in your learning process.
I will try to help you with the skeleton of the things that you need to ponder over here :
1. You have a source path : src : /opt/x/jboss/jvm/log/
2. You have a destination path : dest : /archive/y/jboss/jvm/
3. Copying one file from src to dest : cp command : cp /filesourcepath /filedestinationpath
4. Rename a file( backing up a file ) : mv command : mv oldfilename newfilename
5. Find command to find files ( for 24 hours ago modified time ) you can use : find "$src" -type f -mtime -1
refer this command man page here for -m directive : https://man7.org/linux/man-pages/man1/find.1.html under positional options --> -daystart
Now if you know these concepts then you will have to create a shell script which will have loop & conditionals eg. for & if-else :
Please note that there can be multiple ways we can achieve it - but the above is the basic logic to achieve this objective.
This is a basic shell script and you should be able to formulate it if you understand the above topics.
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.