Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Help Needed for creating the folder by checking today's date and, take backup using rsync command


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Help Needed for creating the folder by checking today's date and, take backup using rsync command

How to create a shell script to create a folder by using the today's date to take backup using rsync command on every evening around 7 pm.
Kindly help.
Thanks.

To be more precise,
I want to create a script which matches the today's date with server's date format, if matches then creates the folder named date itself in the mentioned path "/tmp/test/files/testing/".
Moreover, after that it searches for the files which are created by today's date by using find command -newermt from some path, lets say "/var/www/path" and rsync command those files into /mnt/.

I'm kinda new shell scripter however, kindly help me with the script.

Thanks,
Bakula

Last edited by bakula10; 06-10-2019 at 08:40 AM..
# 2  
We will help you.
But did you try something ?

If using rsync, examine its options carefully.
Perhaps issuing a find first using absolute path, print its output to file then processes it with rsync
Code:
--files-from=FILE       read list of source-file names from FILE

Or just mkdir and rsync into it, without find execution.

What do you think?

Regards
Peasant
# 3  
This should get you pretty close.

Code:
F_LOC=/tmp/test/files/testing
S_LOC=/var/www/path
R_FILE=/tmp/reffile.$$

trap "rm -f \"${R_FILE}\"" EXIT HUP INT QUIT

today=$(date +%Y%m%d)
touch -t ${today}0000 "${R_FILE}"
[ -d "${F_LOC}/$today" ] || mkdir -p "${F_LOC}/$today"
cd "${F_LOC}"
(  
  cd "${S_LOC}"
  find . -type f -newer "${R_FILE}" -print0
) |  rsync -av0RD --files-from=- "${S_LOC}" "./$today"


You can remove v (verbose) from the rsync options above once you are happy it is working as intended.
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?
MVEERA
Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv.... Shell Programming and Scripting
0
Shell Programming and Scripting
how to use WGET command to get today's date?
newbie09
I need to get the current date off a remote site, such as Google or Yahoo. Does anyone know how to use the wget command on a Solaris 10 system to do this? I recall a long time ago, where using "wget" will get a bunch of info off a site, and then, you can extract the date from all of that info. ...... Shell Programming and Scripting
6
Shell Programming and Scripting
Shell Scripts - shows today’s date and time in a better format than ‘date’ (Uses positional paramete
citizencro
Hello, I am trying to show today’s date and time in a better format than ‘date’ (Using positional parameters). I found a command mktime and am wondering if this is the best command to use or will this also show me the time elapse since 1/30/70? Any help would be greatly appreciated, Thanks...... UNIX for Dummies Questions & Answers
3
UNIX for Dummies Questions & Answers
Backup Script using fbackup command Help Needed.
avik.nandi
Hi Friends, I'm new to unix, I have the below script which takes regular backup. Now if fbackup fails I get the below messages in my log as fbackup(3047): could not open output file /dev/rmt/0m fbackup(3019): would you like to enter a new output file? fbackup(3004): writer aborting...... HP-UX
4
HP-UX
Help needed on Date command
nikunj
Hi, I am facing one problem with date command.Actually I want to use this command to get the last month,not the current month..OK,I can do current month - 1 and give special condition for january,But this time i need last month as strings like January,februaury,march etc... There is option...... Shell Programming and Scripting
5
Shell Programming and Scripting

Featured Tech Videos