Because I am only allowed to have 2 links in my post....here is a list of links that I used:
hastebin.com
Steps
0) SSH into the server. become root:
sudo su
1) Open up MySQL configuration file:
vi /opt/bitnami/mysql/my.cnf
2) Under [client] add your mysql user and password (Note: password must have ""):
[client]
port=3306
socket=/opt/bitnami/mysql/tmp/mysql.sock
user=root
password="password"
3) Save the file.
hit: ESC, type: wq, hit: Enter. (wq = write+quit).
4) Choose location for backup script:
cd /opt/bitnami
5) Create and edit backup script:
vi backup.sh
6) Inside of the vim editor add the following code:
for me the top line became truncated, you might have to type this portion
#!/bin/sh
# What to backup.
backup_files="/opt/bitnami /tmp/crm_db_backup.sql"
# Where to backup to.
dest="/root/backup"
# Staging directory.
stage="/tmp"
# Create archive filename.
# This will give a filename along the lines of "hostname-Year-Month-Day.tgz"
day=$(date +%Y-%m-%d)
hostname=$(hostname -s)
archive_file="$hostname-$day.tgz"
# Print start status message.
echo "Backing up CRM............................"
date
echo
# Print start MySQL Dump message.
echo "Dumping MySQL to $stage................................................"
date
echo
# Dump MySQL
mysqldump --databases bitnami_suitecrm > /tmp/crm_db_backup.sql
# Print start Compression message.
echo "Compressing to $dest/$archive_file........................."
date
echo
# Backup the files using tar.
tar czPf $dest/$archive_file $backup_files
# Print end status message.
echo "Backup Complete......................................................"
date
echo
# Print end Cleanup message.
echo "Removing Temp Files.................................................."
date
echo
# Clear Staging files
rm /tmp/crm_db_backup.sql
# Print Final size and location.
echo "Final backup Size and Location......................................."
date
echo
# Long listing of files in $dest to check file sizes.
ls -lh $dest
echo
If you have an FTP server and want to transfer the backup, append this to the file.
# Print Start FTP.
echo "Execute FTP Transfer................................................."
date
echo
# FTP backup remote
ftp='ftp.server.address'
user='ftp_username'
passwd='ftp_password'
ftp -inv << EOF
passive
open $ftp
user $user $passwd
# If you are using Glacier + CloudGates you will want to move into the '/incoming' directory of the FTP.
# cd /incoming
lcd $dest
mput $archive_file
EOF
echo
# Print FTP end status message.
echo "FTP Transfer Complete..............................................."
date
echo
If you are using FTP and want to save disk space on your server, delete the .tgz file.
# Remove Backup .tgz
echo "Removing .tgz Backup File............................................"
rm /root/backup/$archive_file
echo
7) Save the file.
hit: ESC, type: wq, hit: Enter. (wq = write+quit).
8) You should now have edited MySQL my.cnf, and created a backup.sh, have an accessible directory to save the backup to, in the example I used '/root/backup' (whether its temporary or not).
9) Make sure that the script is execute worthy:
chmod +x /path/to/script/backup.sh
10) Before setting up an automatic backup make sure that the script works.
If you are using FTP to store the backup I suggest first testing the actual backup of the bitnami folder + sql dump.
11) Next step is to setup the cron inside of the crontab file.
Cron allows us to schedule when to run the script. If you are using Schedulers from within SuiteCRM you would have already edited this file.
12) Open up the crontab file:
vi /etc/crontab
Either edit the crontab file directly or copy and paste the command using this website: crontab-generator visit hastebin link:(5)
13) You should see something like this:
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
14) You will want to add:
0 12 * * * root /opt/bitnami/backup.sh >/dev/null 2>&1
The ' 0 12 * * * ' means it will run every day at 12:00 p.m. server time. If you want a different schedule use: crontab-generator visit hastebin link:(5)
>/dev/null 2>&1 means that the output of the script when it is running will be sent to /dev/null, /dev/null is a black hole.
15) Save the file.
hit: ESC, type: wq, hit: Enter. (wq = write+quit).
16) How can I see if the cron job is working?
grep -i cron /var/log/syslog
example output:
Apr 6 20:50:01 CRON[12660]: (root) CMD ( /opt/bitnami/backup.sh >/dev/null 2>&1)
Thanks for reading, hope this helped.