backup | LinuxHostSupport Linux Tutorials and Guides Sun, 02 Aug 2020 16:41:40 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.1 How to Back Up Your PostgreSQL Database https://linuxhostsupport.com/blog/how-to-back-up-your-postgresql-database/ https://linuxhostsupport.com/blog/how-to-back-up-your-postgresql-database/#respond Wed, 15 Aug 2018 09:29:24 +0000 https://linuxhostsupport.com/blog/?p=642 Database backups are extremely important and absolutely necessary for protection against data loss. The lack of database backups can totally mess up business operations and can be devastating for a business. In this tutorial below we will teach you how to backup a PostreSQL database. PostgreSQL is an object-relational database management system used by many […]

The post How to Back Up Your PostgreSQL Database appeared first on LinuxHostSupport.

]]>
Database backups are extremely important and absolutely necessary for protection against data loss. The lack of database backups can totally mess up business operations and can be devastating for a business. In this tutorial below we will teach you how to backup a PostreSQL database. PostgreSQL is an object-relational database management system used by many developers to store and manipulate data for their applications and websites.

When you are storing important data in a PostgreSQL database like information about your customers, products, sales, employees etc. you need to make sure you have a full backup of that database. Performing regular database backups very important as it will save you lot of time in case of data loss. When you install PostgreSQL on a Linux VPS, it includes tool which helps you to better manage the database service. There is also a tool for generating database backups and it is really easy to use. Follow the steps bellow to find out.

How to backup a PostgreSQL database on a Linux VPS

One of the prerequisites is to have SSH access to your server. If you do have access to it, connect to your Linux VPS via SSH. Once you are connected to the server, switch to the postgres user using the following command:

su - postgres

postgres is the superuser in PostgreSQL and you can use it to perform many different operations like adding users, creating or deleting databases, assigning roles etc. In this case you will be using the superuser to generate a backup of your PostgreSQL database.

To backup a single database you can use the pg_dump tool which is installed by default with your PostgreSQL service. You can use it no matter if you have an Ubuntu VPS or CentOS VPS. When you are using this tool to generate a backup of specific database, you should use the following syntax:

pg_dump [connection-option ...] [option ...] [dbname]

Now, to create a plaintext dump of the database, you can use the command bellow:

pg_dump database-name > database-name.sql

If you are not sure about the name of the database you are using for your application, you can easily check this with the psql tool. This tool is also included with the PostgreSQL service during installation. Therefore, while logged in as postgres user, type psql in your terminal to activate the PostgreSQL interactive terminal:

postgres@host:~$ psql
psql (9.5.13)
Type "help" for help.

postgres=#

Here, type \l to list all of your PostgreSQL databases. The output will be similar to the one below, except there will be more databases:

postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
testdb | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)

Now, lets say you want to backup the testdb. The command you need to use is the following:

pg_dump testdb > testdb.sql

How to backup all your PostgreSQL databases on a Linux VPS

The pg_dumpall tool that also comes with PostgreSQL allows you to backup multiple databases at once. You can use it to create a full backup of all your PostgreSQL database. To do that, run the command below in your terminal:

pg_dumpall > alldbs.sql

This will create a plaintext dump of all your databases currently stored in PostgreSQL so you can restore them later if needed.

How to restore PostgreSQL database on a Linux VPS

The psql tool also allows you to easily restore a database from backup if needed. To restore a database from backup, you can simply run the following command in your terminal:

psql database-name < database-name.sql

Of course, you need to replace database-name in the previous command with the name of your database. The restore operation will take some time depending on the size of the backup.

You can also restore all database from a previous backup using the following command:

psql -f alldbs.sql postgres

Make sure you replace alldbs.sql with the name of the database backup file.

Back Up your PostgreSQL database

For more information and usage examples about these PostgreSQL tools we recommend you to check their respective documentation pages. The documentation for pg_dump is available here, for psql here, and for pg_dumpall it is available here.

And that’s it, you have successfully learned to back and restore PostreSQL databases. We strongly suggest you do a regular daily backups of your databases and keep them in a safe place.


You really don’t need to back up or restore PostreSQL database if you use one of our premium server management services, in which case our system administrators will take care of your database backups, professionally and efficiently.

The post How to Back Up Your PostgreSQL Database appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-back-up-your-postgresql-database/feed/ 0
How to Restore a Full cPanel Backup to VPS https://linuxhostsupport.com/blog/how-to-restore-a-full-cpanel-backup-to-vps/ https://linuxhostsupport.com/blog/how-to-restore-a-full-cpanel-backup-to-vps/#respond Wed, 25 Oct 2017 13:00:46 +0000 https://linuxhostsupport.com/blog/?p=249 Backup restoration is one of the essential tasks every server administrator must know how to perform. Under cPanel it is really simple to restore full backup of one account. In this tutorial we are going to show you two very easy methods about how to restore a full cPanel backup to a Linux VPS. Restore […]

The post How to Restore a Full cPanel Backup to VPS appeared first on LinuxHostSupport.

]]>
Backup restoration is one of the essential tasks every server administrator must know how to perform. Under cPanel it is really simple to restore full backup of one account. In this tutorial we are going to show you two very easy methods about how to restore a full cPanel backup to a Linux VPS.

Restore Full cPanel Backup via WHM

The first method is to restore the full cPanel backup via WHM. Of course, in order to be able to restore the backup using this method you need to have root access to WHM which is listening on port 2087. So if your domain is example.com, you can access WHM via web browser at https://example.com:2087.

Once you log in to WHM, navigate to Backups and then select Restore a Full Backup/cpmove File. This WHM feature will allow you to restore specific backup by choosing one of the two possible methods, Restore with Username or Restore with File.

To restore with username, you must upload the full cPanel backup file to one of the following directories:

/home
/home2
/home3
/root
/usr
/usr/home
/web

Additionally, the filename of the full cPanel backup must use one of the following formats:

cpmove-{USER}
cpmove-{USER}.tar
cpmove-{USER}.tar.gz
{USER}.tar
{USER}.tar.gz
backup-{BACKUP-DATE_TIME}_{USER}.tar
backup-{BACKUP-DATE_TIME}_{USER}.tar.gz

For example, if the username for the account you want to restore is example_user you should select the username from the drop down list. See the screenshot below for more details.

How to Restore a Full cPanel Backup to VPS

If there is no full cPanel backup uploaded in one of the above directories for that username, it will not be available for selection. Therefore, make sure that the full cPanel backup is properly uploaded on your cPanel server.

Once you are ready to restore the backup, hit the Restore button and let cPanel do its work.

In case you want to restore a full cPanel backup using a file, select Restore with File, then click on Choose file and select the backup file from your local filesystem. The backup file will be uploaded on the server and restored.

Restore Full cPanel Backup via command line

Yes, this is another method which some server admins find much easier than the first one. For this method you need to have SSH access to the server. Connect to your Linux server via SSH and run the following command as root:

/scripts/restorepkg example_user

Of course, you need to replace example_user with the actual username for the account you want to restore. Also, make sure that the full cPanel backup is properly uploaded in the /home directory on your server before starting the restoration process.

For more information we recommend you to refer to the WHM/cPanel documentation. The article describing the full cPanel backup restoration process is available at https://documentation.cpanel.net/display/ALD/Restore+a+Full+Backup+cpmove+File.

Restoring full cPanel backup on a Linux VPS is an easy task if you use one of our Linux Host Support Services. Simply ask our expert Linux Administrators to help you restore the full cPanel backup on your server for you, and it will be taken care of immediately. They are available 24×7, so you can get the help you need at any time.

PS. Feel free to share this blog post if you liked it by using the social network shortcuts – you can also leave a comment instead, found under the share buttons.

The post How to Restore a Full cPanel Backup to VPS appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-restore-a-full-cpanel-backup-to-vps/feed/ 0
How to backup a WordPress site on your VPS https://linuxhostsupport.com/blog/how-to-backup-a-wordpress-site-on-your-vps/ https://linuxhostsupport.com/blog/how-to-backup-a-wordpress-site-on-your-vps/#comments Fri, 01 Sep 2017 09:19:16 +0000 https://linuxhostsupport.com/blog/?p=195 In this tutorial, we will show you how to manually backup your WordPress site on your VPS. It is highly recommended that you make regular backups of your WordPress site so you can easily restore it if something unexpected happens, for example, if your site breaks because of a faulty plugin, it gets infected with […]

The post How to backup a WordPress site on your VPS appeared first on LinuxHostSupport.

]]>
In this tutorial, we will show you how to manually backup your WordPress site on your VPS. It is highly recommended that you make regular backups of your WordPress site so you can easily restore it if something unexpected happens, for example, if your site breaks because of a faulty plugin, it gets infected with malicious files, you accidentally delete the contents of our database and so on. In order to fully make a backup of your WordPress site, we will need to make a backup of your WordPress files and your WordPress database.

WordPress Files

First, we will make a backup of all of your WordPress site files.

To do so, you need to log in to your VPS via SSH.

Once logged in, you will need to navigate to your WordPress root directory. Depending on your server configuration this can be at a different location, for example, /var/www/html/wordpress/.

Your WordPress site consists of the following:

  • the WordPress core installation files (stored in the wp-admin directory).
  • the WordPress Themes and Plugins (stored in the wp-content directory).
  • libraries and third-party components (stored in the wp-includes directory).
  • Images and Files
  • JavaScript and PHP scripts
  • Additional files and static web pages

All of these together will generate your WordPress site, so it would be best to backup all of these files and directories.

It is usually enough to only copy your wp-content directory, as the contents of wp-admin and wp-includes are usually never modified, and you can always retrieve them from the original WordPress installer.

But, just so you can have a full working copy of our site, it would be a good idea to make a backup of all the WordPress files together.

So, if your WordPress root directory is located in /var/www/html/wordpress/, you can do this with the following command:

tar -cpzf wp-backup.tar.gz /var/www/html/wordpress/

This will create an archive file of all the WordPress files which generate your website.

WordPress Database

Your WordPress files alone are not enough if we want a complete backup of your website. All the information of your website, including your posts, comments, site configurations, user accounts and so on, is stored in your database.

You can make a full backup of your WordPress database with the following command:

mysqldump -u wp_user -p wp_database > wp_database_backup.sql

where “wp_user” is the name of the user of your WordPress database, and “wp_database” is the name of your database.

If you are not sure of the user, database name and password, you can find that information in the wp-config.php file inside your WordPress directory.

With this, you now have everything you need to successfully restore your WordPress site.

After you have successfully made a backup of both your WordPress files and database you can easily transfer them to your local computer via FTP or the other way around when you need to restore your website.

 

Of course, if you are one of our Linux Host Support customers, you don’t have to do any of this, simply ask our admins, sit back and relax. Our admins will make a backup of your WordPress site for you immediately.

PS. If you liked this post, on How to install Monica on Ubuntu 16.04, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.

The post How to backup a WordPress site on your VPS appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-backup-a-wordpress-site-on-your-vps/feed/ 3