Category: Shell Scripting

gtop main 520x245 - Creating Custom Commands in Unix/Linux 0

Creating Custom Commands in Unix/Linux

Working smart means bringing maximum production from your work. In day to day life, Unix/Linux users encounter some certain set of commands which need to be executed quite frequently. Executing these commands on a regular basis may become quite irritating sometimes. Unix/Linux systems allow us to create custom commands to cope up with this situation. Instead of executing the same set of commands every time, we can put these commands...

Amazon s3 Backup 520x245 - Shell Script for backing up data to Amazon s3 1

Shell Script for backing up data to Amazon s3

s3cmd is a command line tool for saving, retrieving, uploading and managing data from Amazon s3. Its capacity to store huge amount of data on nominal charges, Amazon s3 is becoming one of the most suitable choices for storing data remotely. Pre-Requests Install amazon s3 cli on ec2. Create IAM role with s3 Access Configure s3cmd on ec2. Create Amazon s3 bucket for the backup process. Basic Bash Script, can be modified...

shell 199712 640 520x245 - MySQL Database Backup | Bash Scripting 0

MySQL Database Backup | Bash Scripting

MySQL Database Backup | Bash Scripting #!/bin/bash TIMESTAMP=$(date +”%F”) BACKUP_DIR=”/backup/databases/$TIMESTAMP” MYSQL_USER=”username” MYSQL_PASSWORD=”userpass” MYSQL=”$(which mysql)” MYSQLDUMP=”$(which mysqldump)” mkdir -p $BACKUP_DIR find “$BACKUP_DIR” -mtime +3 -type d -exec rm -rf {} \; databases=`$MYSQL -u$MYSQL_USER -p$MYSQL_PASSWORD -e “show databases”| grep -Ev “(database|Database|information_schema|performance_schema|phpmyadmin|mysql)”` for db in $databases; do $MYSQLDUMP -u $MYSQL_USER -p$MYSQL_PASSWORD –databases $db > $BACKUP_DIR/$db.sql done Making the sqlbak.sh file executable. chmod 755 sqlbak.sh Quick explanation of MySQL database backup shell script Shell...