Search for:
Backup MySQL Databases with AutoMySQLBackup on Ubuntu 17.04 | 17.10

Backup MySQL Databases with AutoMySQLBackup on Ubuntu 17.04 | 17.10 &-8211; this Article or News was published on this date:2020-09-27 21:17:38 kindly share it with friends if you find it helpful

AutoMySQLBackup is a free opensource tool that automatically backs-up all the databases hosted on a MySQL server at varying intervals. It’s a great tool that may come in handy in a time of trouble. Not only can it backup MySQL databases automatically, it also comes with many features like email notifications, incremental backups, back up compression and encryption.

If you’re looking for a simple yet powerful tool to automatically backup MySQL databases, you may want to try this. You probably won’t regret it.

This brief tutorial is going to show you how to install and configure in on Ubuntu servers.

To get it installed and configured, follow the steps below

Step 1: Install AutoMySQLBackup

This post assumes you already have MySQL server installed and have few databases to backup. If you haven’t done that, please search on this blog to find easy tutorials on installing MySQL or MariaDB servers.

When you have MySQL server installed and few databases created, continue below to install AutoMySQLBackup.

Run the commands below to install the tool.

sudo apt-get update
sudo apt-get install automysqlbackup

During the installation, you’ll be prompted to choose a mail configuration as shown below.. Select Internet Site if you’re going to be setting up email notification. If not, then just select No configuration.

Please select the mail server configuration type that best meets your needs.
No configuration:
Should be chosen to leave the current configuration unchanged.
Internet site:
Mail is sent and received directly using SMTP.
Internet with smarthost:
Mail is received directly using SMTP or by running a utility such
as fetchmail. Outgoing mail is sent using a smarthost.
Satellite system:
All mail is sent to another machine, called a 'smarthost', for delivery.
Local only:
The only delivered mail is the mail for local users. There is no network.
General type of mail configuration:

                    No configuration
                    Internet Site
                    Internet with smarthost
                    Satellite system
                     Local only
         Ok>                                       Cancel> 

 

After selecting your options, select Ok to continue with the installation.

Step 2: Configure AutoMySQLBackup

Now that the tool is installed, go and configure it. I couldn’t find any configuration file crated, so I had to create one myself. The default configuration directory for AutoMySQLBack is at:

/etc/automysqlbackup/

Create a new configuration file with the parameters as shown below. Run the commands below to create a new configuration file.

sudo nano /etc/automysqlbackup/automysqlbackup.conf

Then add the content below into the file and save.

CONFIG_mysql_dump_username='root'
CONFIG_mysql_dump_password='root_password'
CONFIG_mysql_dump_host='localhost'
CONFIG_backup_dir='/var/backup/db'
CONFIG_do_monthly="01"
CONFIG_do_weekly="5"
CONFIG_rotation_daily=6
CONFIG_rotation_weekly=35
CONFIG_rotation_monthly=150
CONFIG_mysql_dump_port=3306
CONFIG_mysql_dump_compression='gzip'

Save the file

Now to run the backup manually, just type the commands below.

sudo automysqlbackup

To automatically run the backup daily, run the commands below.

sudo ln -s /usr/sbin/automysqlbackup /etc/cron.daily/

That’s it!

Also look in the folder below for back up jobs that were run manually.

/var/lib/automysqlbackup

Summary:

This post shows students and new users an easy want to automatic MySQL backup on Ubuntu. With AuthMySQLBackup tool, one can set a backup job to run daily, weekly or monthly.

The job will then backup all MySQL databases and store them in the location specify.

Enoy!

You may also like the post below

Installing Nginx, MySQL and PHP (LEMP) on Ubuntu 17.04 | 17.10

Installing Nginx, MySQL and PHP (LEMP) on Ubuntu 17.04 | 17.10 &-8211; this Article or News was published on this date:2020-09-27 21:17:34 kindly share it with friends if you find it helpful

This brief tutorial shows students and new users how to install Nginx, MySQL and PHP (LEMP) on Ubuntu 17.04 | 17.10 servers or VPS. LEMP is an acronym for Linux, Nginx (aka engine-x), MySQL and PHP.

LEMP, a stack of opensource applications that powered many of the PHP-based websites and web applications online today. LEMP and LAMP are similar except LAMP uses Apache2 webserver and LEMP uses Nginx.

LEMP is rapidly gaining popularity because it provides speed and scalability.

Continue with the steps below to get LEMP installed.

Step 1: Install / Update Ubuntu Server

LEMP won’t exist without a Linux system. For this post, we’re going to be using Ubuntu as our Linux machine.

This post assumes that you already have Ubuntu server installed and that you have administrative rights to install packages and make changes to the server.

After installing Ubuntu, run the commands below to update the server

sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove

You may have to reboot the systems after running the commands above..

Step 2: Install Nginx Webserver

Now that Ubuntu is updated, run the commands below to install Nginx webserver

sudo apt-get install nginx

After installing Nginx, the commands below can be used to stop, start, and enable Nginx webserver to always start up when the server boots.

sudo systemctl stop nginx.service
sudo systemctl start nginx.service
sudo systemctl enable nginx.service

After installing Nginx, test it out by browsing to the server IP address or hostname. When you see the page below, then Nginx is installed and functioning.

nginx default home page test

Step 3: Install MySQL Server

After installing Nginx above, the commands below show you how to install MySQL Server.

sudo apt-get install mysql-server mysql-client

Shortly after continuing with the installation, you’ll be prompted to create and confirm MySQL root user password. Please create a strong password for security.

nginx default home page test

After installing MySQL database server, the commands below show you how to stop, start and enable MySQL to always start up with the system boots.

sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service

Now that MySQL is installed, run the commands below to secure it.

sudo mysql_secure_installation

Use the guide below to answer the questions when asked.

Enter password for user root: TYPE CURRENT ROOT PASSWORD

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.

Estimated strength of the password: 50 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

After that, MySQL should be ready to use. To test whether MySQL is functioning, run the commands below to logon.

sudo mysql -u root -p

Enter the password you created earlier in the post and you should see MySQL welcome message.

Step 4: Install PHP-FPM and Related Modules

Lastly, run the commands below to install PHP and related PHP modules.

sudo apt-get install php-fpm php-mysql

The commands above will install PHP, but may also install Apache2 webserver. Run the commands below to disable Apache2 from starting.

sudo systemctl disable apache2.service

Remove Apache2 default index.html page.

sudo rm /var/www/html/index.html

To run PHP-based websites on Nginx you’ll want to edit its default site configuration file. Run the commands below to create a backup of the default file.

sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak

Then edit the default file and make the highlighted changes below

sudo nano /etc/nginx/sites-available/default

Then make the highlighted change.

server {
        listen  80 default_server;
        listen [::]:80 default_server;
        server_name  _;
        root /var/www/html;
        index index.php index.html;

        location / {
                try_files $uri $uri/ =404;
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;

        location = /50x.html {
                root /var/www/html;
        }

        location ~ .php$ {
                include snippets/fastcgi-php.conf;
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}

Restart Nginx

sudo systemctl restart nginx.service

Now, create a test PHP file to test.

sudo nano /var/www/html/phpinfo.php

Add the content below in the file and save.

?php
phpinfo();
?>

Now browse to the server IP or hostname followed by /phpinfo.php

You should see PHP file as below. This shows that PHP is functioning with Nginx.

nginx default home page test

Congratulations, you’ve installed LEMP.

Summary:

This post shows how to install Nginx, MySQL and PHP (LEMP) on Ubuntu 17.04 | 17.10.  LEMP is an alternative to LAMP and it’s rapidly gaining popularity because its speed and scalability.

When the above steps are followed, you should be able to quickly run dynamic PHP-based websites and applications.

Enjoy!

You may also like the post below:

Installing Nginx, MariaDB and PHP (LEMP) on Ubuntu 17.04 | 17.10

Installing Nginx, MariaDB and PHP (LEMP) on Ubuntu 17.04 | 17.10 &-8211; this Article or News was published on this date:2020-09-27 21:17:32 kindly share it with friends if you find it helpful

LEMP is an acronym for Linux, Nginx (Engine-x) MariaDB and PHP. It’s based on a collection of opensource software that powers many popular websites and web applications.

One can use LEMP to run WordPress, Joomla, Drupal and other PHP-based content management systems on Linux machines.

This brief tutorial is going to show students and new users how to easily install the LEMP stack on Ubuntu 17.04 | 17.10 if you haven’t already done so.

To get started with install LEMP, follow the steps below:

Step 1: Ubuntu

The LEMP or LAMP stack always begins with the Linux systems. There are many Linux distributions in used today, however, the most popular is Ubuntu. For this post, we’re going to be using Ubuntu Linux as our LEMP based system.

This post also assumes that you have already installed Ubuntu and that you have administrative rights to install packages and make changes.

After installing Ubuntu, run the commands below to update the Ubuntu machine.

sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove

You may want to restart the machine after running the commands above..

Step 2: Install Nginx

Now that the Ubuntu machine is updated, run the commands below to install Nginx web server. Nginx is an alternative to Apache2 and uses system resources very efficiently.

sudo apt-get install nginx

After installing Nginx, the commands below can be used to stop, start and enable Nginx webserver to always start up when the system boots.

sudo systemctl stop nginx.service
sudo systemctl start nginx.service
sudo systemctl enable nginx.service

To test whether Nginx is working, open your browse and browse to the server IP or hostname and you should see Nginx’s default welcome page.

Nginx web server default test page

Step 3: Install MariaDB

MariaDB is a fork and a drop-in replacement for MySQL. MariaDB is an alternative to MySQL and is rapidly gaining popularity. To install MariaDB, run the commands below.

sudo apt-get install mariadb-server mariadb-client

After installing MariaDB, the commands below can be used to stop, start and enable MariaDB to always start up when the system boots.

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Another thing to do after installing MariaDB is to secure it. To do that, run the commands below.

sudo mysql_secure_installation

You’ll be prompted with series of questions, follow the guide below to answer

Enter current password for root (enter for none): PRESS ENTER

Set root password? [Y/n] Y
CREATE YOUR PASSWORD

Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

To test whether MariaDB is functioning, run the commands below to logon to the server.

sudo mysql -u root -p

When prompted for the password, type the password you created above to logon. If you successfully logon, you should see MariaDB welcome message.

Step 4: Install PHP-FPM and Related Modules

PHP is the last component of LEMP. It allows dynamic websites and applications to be created. Majority of the CMS in used today are using PHP. To install PHP and related modules, run the commands below

sudo apt-get install php-fpm php-mysql php-curl php-gd php-pear php-imagick php-imap php-mcrypt php-recode php-tidy php-xmlrpc

Now that PHP-FPM is installed, go and open Nginx default site configuration file and make sure the lines below are not commented out.

sudo nano /etc/nginx/sites-available/default

Then make the highlighted changes below and save the file.

server {
	listen 80 default_server;
	listen [::]:80 default_server;
        ............
        ............

        index index.php index.html index.htm;

        - pass PHP scripts to FastCGI server
        -
        location ~ .php$ {
        include snippets/fastcgi-php.conf;
        -
        - - With php-fpm (or other unix sockets):
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;        -Ubuntu 17.10
      - fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;        -Ubuntu 17.04
       - - With php-cgi (or other tcp sockets):
       - fastcgi_pass 127.0.0.1:9000;
  }
  ..........

After saving the file above, reload Nginx configuration settings by running the reload commands.

sudo systemctl reload nginx.service

To test whether PHP is installed and functioning, create a test PHP script in Nginx document root directory by running the commands below.

sudo nano /var/www/html/phpinfo.php

Then copy and paste the content below in the file and save.

?php
phpinfo();
?>

After saving the file, open your browser and browse to the server IP or hostname.. and you should see PHP test info page.

http://hostname/phpinfo.php
Nginx web server default test page

This is how to install LEMP on Ubuntu.

Summary:

This post shows students and users how to easily install Nginx, MariaDB and PHP on Ubuntu servers. It’s a beginning to running dynamic websites and applications based on PHP.

If you’re going to be running most content management systems, then this might be the first post to read.

Enjoy!

You may also like the post below:

Quickly Get LetsEncrypt Certificates for Apache2 on Ubuntu 17.04 /17.10

Quickly Get LetsEncrypt Certificates for Apache2 on Ubuntu 17.04 /17.10 &-8211; this Article or News was published on this date:2020-09-27 21:17:27 kindly share it with friends if you find it helpful

This brief tutorial shows students and new users how to quickly obtain LetEncrypt SSL/TLS certificates for your domain using Apache2 webserver on Ubuntu 17.04 | 17.10 systems. For those who don’t know, LetEncrypt is an opensource initiative to provide free SSL certificates to anyone with valid domains.

With LetEncrypt, you will never have to pay for another SSL/TLS certificate again. This post you’re ready today is encrypted via LetEncrypt and renewed every 60 days automatically.

So, if you’re running Ubuntu 17.04 | 17.10 with Apache2 installed, follow the steps below to get a free SSL/TLS certificates for your domains.

Step 1: Get Ubuntu / Apache2

This post assumes that you already have Ubuntu server with Apache2 webserver installed. If not, search this blog to find tutorials on installing Ubuntu and Apache2.

Or run the commands below to install Apache2

sudo apt-get install apache2

After installing Apache2, the commands below can be used to stop, start and enable Apache2 to always startup when the server boots.

sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

Step 2: Installing LetEncrypt SSL/TLS Management Package

On Ubuntu systems, simply run the commands below to get LetEncrypt package. The package can then be used to obtain certificates for your domains.

sudo apt-get install python-certbot-apache

After running the commands above, your system should be ready to obtain certificates. But before you run the commands to obtain certificates, verify that the your domain name is setup in Apache2.

Step 3: Obtaining LetsEncrypt Certificates

To obtain LetEncrypt SSL/TLS certificates, run the commands to open Apache2 configuration file and add the domain names directives.

sudo nano /etc/apache2/sites-available/000-default.conf

Then verify that these lines are included

ServerName       example.com
ServerAlias      www.example.com

After verifying that information, run the commands below to obtain your certificates.

sudo certbot --apache -m [email protected] -d example.com -d www.example.com

Replacing www.exmaple.com and example.com with your domain name.

When you run the commands above, you must accept the terms.. Type A to accept.

Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf. You must agree
in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A

You may also want to share your email with the Electronic Frontier Foundation..

Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o: Y

Now all you do is sit back and relax.. LetsEncrypt will install and configure Apache2 with a valid SSL/TLS certificate. To correctly Apache2 up to handle all redirects to HTTPS, select option -2

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
-------------------------------------------------------------------------------
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):2

This is how easy it is to setup LetEncrypt SSL/TLS for Apache2 on Ubuntu 17.04 | 17.10 systems.

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/example.com/privkey.pem
   Your cert will expire on 2018-02-24. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:
   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

To get setup a process to automatically renew the certificates, add a cron job to execute the renewal process.

sudo crontab -e

Then add the line below and save.

0 1 * * * /usr/bin/certbot renew & > /dev/null

The cron job will attempt to renew 30 days before expiring.

Summary:

This post shows students and new users how to easily install and obtain LetEncrypt SSL certificates for Apache2 on Ubuntu system. After setting it up, you’ll never have to pay for certificates again.

Enjoy!

You may also like the post below:

How to Install Ghost on Ubuntu 17.04 | 17.10

How to Install Ghost on Ubuntu 17.04 | 17.10 &-8211; this Article or News was published on this date:2020-09-27 21:17:17 kindly share it with friends if you find it helpful

This post shows new users and students how to easily install Ghost on Ubuntu 17.04 | 17.10. Ghost is a fairly new blogging platform powered by Node.js. Ghost is a very clean and lightweight platform designed for bloggers who want to focus on blogging and nothing else.

Unlike WordPress and other content management systems based on PHP, Ghost simple in design and function. No additional packages and server needed, just JavaScript.

To get Ghost quickly running on Ubuntu, follow the steps below

Step 1: Update Ubuntu

Before installing Ghost or any other packages in Ubuntu, it’s recommended that you update the server. To do that, run the commands below

sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove

After running the commands above, you may want to restart the server.

Step 2: Install Node.js package

Since Ghost is based on Node.js run the commands below to download Node.js packages from its repository

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -

Next, run the commands below to install Node.js and required packages in order for Ghost to function. Nginx webserver will be needed for this. s

sudo apt-get install nodejs

Step 3: Install and Configure Ghost

Now that you’ve install Node.js and other packages that Ghost needs, let’s go and download Ghost packages from its repository. To do that, run the commands below.

wget https://ghost.org/zip/ghost-latest.zip -O ghost.zip

The commands above download the latest version of Ghost packages.

After downloading Ghost package, run the commands below to create Ghost document root directory.

sudo mkdir -p /var/www/html/ghost/

Then unzip Ghost package in the root directory.

sudo unzip ghost.zip -d /var/www/html/ghost/

Now change into the root directory and install Ghost

cd /var/www/html/ghost
sudo npm install --production

Wait for the installation to complete.

After the installation completes, run the commands below to create Ghost configuration file from its example file.

sudo cp config.example.js config.js

Then open the configuration file and configure make sure the content looks like the highlighted one below.

sudo nano config.js

Validate that you configure the settings below to match your server. The URL is the URL to access the site.

// --- Production
// When running Ghost in the wild, use the production environment.
// Configure your URL and mail settings here
production: {
url: 'http://myghost.com',
mail: {},
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost.db')
},
debug: false
},

server: {
host: '0.0.0.0',
port: '2368'
}
},

Make the change and save the file.

After saving the file, run the commands below to start Ghost.

sudo npm start --production

Ghost by default runs on port &-8211; 2368. You must type the port number after the URL to access.

ex. http://myghost.com:2368

Ghost should be accessible.

ghost ubuntu

To create an account, type URL followed by /ghost/signup

ex. http://myghost.com:2368/ghost/signup

Step 4 Install Nginx Webserver as Proxy

Since you must always type the hostname followed by the port number to access Ghost, which you probably don’t want your users to type, you must install Nginx and configure it as a proxy server for Ghost. To do that follow the steps below.

sudo apt-get install nginx

Then create a ghost config file by running the commands below.

sudo nano /etc/nginx/conf.d/ghost.conf

Then copy and paste the content below into the file, then save.

server {
    listen 80;
    listen [::]:80;
    server_name myghost.com www.myghost.com;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://127.0.0.1:2368;
    }
}

Restart Nginx and connect to your site via its domain or hostname.

sudo systemctl restart nginx

Congratulations! You’ve just installed Ghost on Ubuntu

Enjoy!

You may also like the post below: