Database Backup
You might ask yourself, how do I back up my databases? We use mysqldump.
Here is how you do it:
$ mysqldump -u root -p --all-databases > backup.sql
You can also set yourself up an alias like this:
NOTE: remember to change /path/to/backdir/backup.sql to a directory you want your backups to go.
$ cat >> ~/.bashrc << EOF
# add alias to generate mysql user passwords
alias mybackup='mysqldump --defaults-extra-file=~/.mysql-defaults --all-databases > /path/to/backdir/backup.sql.$(date +%y.%m.%d)'
EOF
make active
$ source ~/.bashrc
Then, we when want to back up our database, we just type:
$ mybackup
My backup will create a file that looks similar to this:
backup.sql.20.04.20
The date is listed at the end in Year.Month.Day format.