Thursday, August 20, 2015

AUTOMATE MIGRATION OF CATALOG IN LINUX

Lets see today how to automate webcatalog migration. I found this more useful in taking daily/ weekly/ monthly back up of catalog
Approach:
1. Write the script to Zip the catalog and move it to different folder or server
2. Schedule this script to run on daily/ weekly/ monthly basis as per requirement.
1. Archiving the catalog
Use the following Script:
tar -zcvf $(date ‘+%d_%m_%y_%H_%M’)_DEVCATALOGBkUp.tar.bz2{{Destination}}>Output_report.txt
echo “Done”
Here
{{Destination}} – represents the full path of folder where archive is to be created
z – This option tells tar to read or write archives through gzip, allowing tar to directly operate on several kinds of compressed archives transparently.
c – Create a new archive
v – Operate verbosely
f – Use archive file
(date ‘+%d_%m_%y_%H_%M’) – this will append the current date before the name of folder.
Save the file as Catalog_Backup.sh
2. Scheduling the Shell script.
Use the cron command to schedule the Catalog_Backup.sh as per intended backup frequency.
crontab [-u user] [-l | -r | -e] [-i]
-u Append the name of the user whose crontab is to be tweaked. If this option is not given, crontab examines “your” crontab, i.e., the crontab of the person executing the command.
-l Display the current crontab.
-r Remove the current crontab.
-e Edit the current crontab, using the editor specified in the VISUAL or EDITOR environment variables.
i Same as -r, but gives the user a “Y/n” prompt before actually removing the crontab.

No comments:

Post a Comment