ownCloud migration in linux

Now a day’s most of the IT companies implemented ownCloud because they are getting more benefits from it and many things were automated. So, today i’m going to explain how to migrate owncloud from one server to another.

New Server

First install the ownCloud to new server then move/copy required files/folders from old server.

1) Download & Install the ownCloud package

Use the below link to download the latest version of ownCloud package then install it.

# Download the ownCloud package #
[email protected] [~]# wget https://download.owncloud.org/community/owncloud-7.0.4.tar.bz2

# Extract the ownCloud archive file #
[email protected] [~]# tar -xjvf owncloud-7.0.4.tar.bz2

# Change folder permission #
[email protected] [~]# chown -R groupname:username owncloud

# Create Database #
mysql> create database cloud;
Query OK, 1 row affected (0.00 sec)

# Create Database user #
mysql> CREATE USER 'cloud'@'localhost' IDENTIFIED BY 'cloud';
Query OK, 0 rows affected (0.00 sec)

# Assign the PRIVILEGES #
mysql> GRANT ALL PRIVILEGES ON cloud.* TO 'cloud'@'localhost';
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

2) Configuration

Navigate your browser to http://Your-domain.com/owncloud, it will ask you to create the username & password to mange your owncloud.

3) Remove data & config folders

Remove data & config from new server.

# Remove data folder #
[email protected] [~]# rm -Rf data

# Remove config folder #
[email protected] [~]# rm -Rf config

Old Server

take backup of database,data & config folders then move/copy to new server.

1) Backup database,data & config folders

Follow the below steps to take backup of required data from old server.

# Database Backup #
[email protected] [~]# mysqldump -u root -p owncloud > owncloud.sql

# Sync Database Backup to new server #
[email protected] [~]# rsync -avz -e "ssh -p 22" /root/owncloud.sql

# Sync data folder #
[email protected] [~]# rsync -avz -e "ssh -p 22" /home/cloudana/public_html/owncloud/data/*

# Sync config folder #
[email protected] [~]# rsync -avz -e "ssh -p 22" /home/cloudana/public_html/owncloud/config/*

New Server

Modify the configuration according to the new server details to make it work on owncloud properly.

# Restore Database Backup #
[email protected] [~]# mysql -u root -p owncloud < owncloud.sql

# Change data folder permission #
[email protected] [~]# chown -R groupname:username data

# Change config folder permission #
[email protected] [~]# chown -R groupname:username config

Modify config.php file

[email protected] [~]# nano config.php
0 => 'New-domain-name',
datadirectory' => '../current-data-directory-location',
'dbname' => 'New-DB-name',
'dbuser' => 'New-DB-User-name',
'dbpassword' => 'New-DB-password',

Goahead and access the owncloud from new server without any issues.

About Prakash Subramanian

Prakash Subramanian is a Linux lover and has 3.5+ years of experience in linux server administration with major Linux distribution such as (RHEL, CentOS, Ubuntu). He is currently working as a Senior L2 Linux Server administrator.

View all posts by Prakash Subramanian

3 Comments on “ownCloud migration in linux”

  1. Can you explain what the mysql commands are doing? I’m not sure I follow exactly what this line is doing and how it relates to users that I may or may not have in my particular installation.
    mysql> GRANT ALL PRIVILEGES ON cloud.* TO ‘cloud’@’localhost’;

Leave a Reply to Magesh Maruthamuthu Cancel reply

Your email address will not be published. Required fields are marked *