ubuntu extra notes

Some extra notes on ubuntu server.

Add mysql that can connect from any where

mysql> CREATE USER ‘monty’@’localhost’ IDENTIFIED BY ‘some_pass’;
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘monty’@’localhost’ WITH GRANT OPTION;
mysql> CREATE USER ‘monty’@’%’ IDENTIFIED BY ‘some_pass’;
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘monty’@’%’ WITH GRANT OPTION;

Rsync to a machine with ssh on port 7822

rsync -avz -e “ssh -p7822” . panos@162.249.6.30:/var/www/gsp –exclude-from app/config/rsync_exclude.txt

Add ubuntu user that can sudo
(thanks to digitalocean)

$sudo adduser panos

reply to all questions asked. To give sudo rights

$ sudo visudo

Search for the line that looks like this:

root ALL=(ALL:ALL) ALL

Below this line, copy the format you see here, changing only the word “root” to reference the new user that you would like to give sudo privileges to:

root ALL=(ALL:ALL) ALL
panos ALL=(ALL:ALL) ALL

Backup mysql and ftp dump to other server

This is a simple solution. Just dumps database and ftp the dump. No timestamp to file name or any other clever things.

Create a shell script eg bck.sh with the lines

cd /home/panos
mysqldump -umyusername -pmypassword –routines mydatabase > mydatabase.sql
tar -zcf mydatabase.sql.tar.gz mydatabase.sql
ftp -in <<EOF
open salix.me
user ftpusername ftppassword
cd public_html/backup
put mydatabase.sql.tar.gz
EOF

where:
myusername and mypassword are mysql credentials
mydatabase is the database to backup
ftpusername and ftppassword as ftp credentials
/home/panos is the folder where you placed the script
public_html/backup is the folder on remote server you want to store the backup

Make it executable

$ chmod +x bck.sh

Then add command to crontab (sudo crontab -e) with a line like this
* 5 * * * /home/panos/bck.sh