====================================
Perform This Task Through Root User
====================================
sudo mkdir /var/Backup/source-code-weekly-incremental-backup
sudo mkdir /var/Backup/database-daily-incremental-backup/
sudo mkdir /var/Backup/mongodb-daily-incremental-backup/
sudo touch /etc/Backup-Script/sourcecode_backup_script.sh
sudo touch /etc/Backup-Script/database_backup_script.sh
sudo touch /etc/Backup-Script/mongodb_backup_script.sh
===============================
Source-Code-Automatic-Backup
===============================
vim sourcecode_backup_script.sh
===============================
Database-Automatic-Backup
===============================
vim database_backup_script.sh
===============================
mongodb-Automatic-Backup
===============================
#!/bin/bash
DUMP='mongodump'
USER='--username'
USERValue='mongo_user'
PASS='--password'
PASSValue='DZF87m6KVVffqwxT'
Database='--db'
DBValue='mongo_db'
$DUMP $USER $USERValue $PASS $PASSValue $Database $DBValue
TIME=`date '+Date_%d_%m_%y_Time_%H_%M_%S'`
FILENAME=mongodump-$TIME.tar.gz
SRCDIR=/home/ubuntu/.backup/dump/
DESDIR=/var/www/mongodb-daily-incremental-backup/
tar -zcf $DESDIR/$FILENAME $SRCDIR
===============================
Cronjob
===============================
10 0 * * 0 /usr/bin/sh /etc/Backup-Script/sourcecode_backup_script.sh >> /var/log/custom_cron.log 2>&1
# This cron job will execute every Sunday at 12:10 AM.
0 0 * * * /usr/bin/sh /etc/Backup-Script/database_backup_script.sh >> /var/log/custom_cron.log 2>&1
# This Cron Is for Mysql DataBase and The Cron Will Exectue Every Day At 12
# Delete Source Code File more than 15 days ago
0 0 * * 0 /usr/bin/find /var/Backup/source-code-weekly-incremental-backup/ -name "*.gz" -type f -mtime +15 -exec rm -f {} \;
# Delete DataBase File more than 10 days ago
0 0 * * 0 /usr/bin/find /var/Backup/database-daily-incremental-backup/ -name "*.gz" -type f -mtime +10 -exec rm -f {} \;
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
1) This script will create a zip file of source code and db when there is a change in the code only and then upload it to S3 bucket.
Link : https://drive.google.com/file/d/1KTezm4TMWLAQUrWqlQKde-U9pRY98Hvn/view?usp=sharing
No comments:
Post a Comment
testing