Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Bash scripts do an excellent job of making life easier in linux environments.
I use this one to make backups of my development site:
archive_instance
#!/bin/bash
#### Script for putting drupal instance source and database content in one file
#### it follows the convention that directory name and database name match
#### eg. if you have drupal instance under sandbox the database name is sandbox, too
E_BADARGS=65
E_NOT_DIREXISTS=99
EXPECTED_ARGS=1
#### apply your settings here
BACKUPPATH=/var/archived_versions/
WWW_ROOT=/var/www/
MYSQLUSER=root
MYSQLPASSWORD=mypass
if [ $# -ne $EXPECTED_ARGS ]
then
echo "This script will backup your site and database into one zip, stored in $BACCKUPPATH"
echo "Usage: $0 sitedir "
echo ":eg $0 sandbox for $WWW_ROOTsandbox and mysqldatabase sandbox"
exit $E_BADARGS
fi
SOURCEDIR=$WWW_ROOT$1
echo $SOURCEDIR
# bash check if directory exists
if [ ! -d $SOURCEDIR ]; then
echo "SOURCE Directory $SOURCEDIR does not exist, please check params"
exit $E_NOT_DIREXISTS
fi
OF=${BACKUPPATH}${1}archive_$(date +%Y_%m_%d_%T).zip
DUMP=${BACKUPPATH}dump_${1}_$(date +%Y%m%d).txt
echo $OF
zip -ru $OF $SOURCEDIR
mysqldump --user=$MYSQLUSER --password=$MYSQLPASSWORD $1 > $DUMP
zip -u $OF $DUMP
rm $DUMP