Getting issue while backing and restoring chef data

Hi All,

My Source and Target chef server version is 12.0.5
(“chef-server-core-12.0.5-1.el6.x86_64.rpm”).

2 Scenarios:

First Scenorios1) Setup target chef-server.
After setting up created user:

[root@chefserverbackup vagrant]# chef-server-ctl user-create takedump Test
Test test@dump.com test@1234 --filename test_chef.key

User is created.

*Second Scenario:*1) I took dump from source chef-server. [I followed the below steps from link : https://docs.chef.io/server_backup_restore.html]

a) Make a postgres export using the following commands:

export THEDATE=`date '+%Y-%m-%d-%H-%M-%S'`
sudo -E -u opscode-pgsql bash
/opt/opscode/embedded/bin/pg_dumpall -c | gzip --fast >

/tmp/postgresql-dump-$THEDATE.gz

b) Synchronize to make sure that all of the data is present on-disk:

sync

c) Backup the /etc/opscode and /var/opt/opscode directories and include the
postgres export file as root

tar cvfzp var-opt-opscode-$THEDATE.tar.gz /etc/opscode
/var/opt/opscode /tmp/postgresql-dump-$THEDATE.gz

2) Restoring on Target server: [setup target chef-server]

a) Stop the server:

$ chef-server-ctl stop

b) Restore the previously backed-up files to the following locations:
/etc/opscode
/var/opt/opscode

by using the following command, which will exclude PostgreSQL files:

tar xvfzp /vagrant/var-opt-opscode-2015-06-19-08-23-26.tar.gz
–exclude=‘var/opt/opscode/postgresql/9.2/data’ -C /

c) Start the postgresql service:

$ chef-server-ctl start postgresql

d) Restore the PostgreSQL database:

    su - opscode-pgsql

    gunzip -c /tmp/postgresql-dump-2015-06-19-08-23-26.gz |

/opt/opscode/embedded/bin/psql -U “opscode-pgsql” -d postgres

    Ignore the following error messages:
        ERROR: current user cannot be dropped
        ERROR: role "opscode-pgsql" already exists

e) Start the server:

$ chef-server-ctl start

Now when I try to login with the user which was existing on my Source
chef-server, I am not able to login

When I try to create a new-user, see the beloww logs:

[root@chefserverbackup vagrant]# chef-server-ctl user-create takedump Test
Test test@dump.com test@1234 --filename test_chef.key
ERROR: Failed to authenticate to https://127.0.0.1:443 as pivotal with key
/etc/opscode/pivotal.pem
Response: An error occurred while trying to find ‘pivotal’. Please
contact support.
[root@chefserverbackup vagrant]# chef-server-ctl user-list
ERROR: Failed to authenticate to https://127.0.0.1:443 as pivotal with key
/etc/opscode/pivotal.pem
Response: An error occurred while trying to find ‘pivotal’. Please
contact support

Thanks,
Chandan

Hi,

Can anyone help here. Aim is to backup and restore chef server data.
Approach and issue i am getting is explained in my previous mail.

Any input is much appreciated

On Sunday, June 21, 2015, Chandan Maheshwari cmaheshwari16@gmail.com
wrote:

Hi All,

My Source and Target chef server version is 12.0.5
("chef-server-core-12.0.5-1.el6.x86_64.rpm").

2 Scenarios:

First Scenorios1) Setup target chef-server.
After setting up created user:

[root@chefserverbackup vagrant]# chef-server-ctl user-create takedump
Test Test test@dump.com <javascript:_e(%7B%7D,'cvml','test@dump.com');>
test@1234 --filename test_chef.key

User is created.

*Second Scenario:*1) I took dump from source chef-server. [I followed the below steps from link : Backup and Restore a Standalone or Frontend install]

a) Make a postgres export using the following commands:

export THEDATE=`date '+%Y-%m-%d-%H-%M-%S'`
sudo -E -u opscode-pgsql bash
/opt/opscode/embedded/bin/pg_dumpall -c | gzip --fast >

/tmp/postgresql-dump-$THEDATE.gz

b) Synchronize to make sure that all of the data is present on-disk:

sync

c) Backup the /etc/opscode and /var/opt/opscode directories and include
the postgres export file as root

tar cvfzp var-opt-opscode-$THEDATE.tar.gz /etc/opscode /var/opt/opscode /tmp/postgresql-dump-$THEDATE.gz

2) Restoring on Target server: [setup target chef-server]

a) Stop the server:

$ chef-server-ctl stop

b) Restore the previously backed-up files to the following locations:
/etc/opscode
/var/opt/opscode

by using the following command, which will exclude PostgreSQL files:

tar xvfzp /vagrant/var-opt-opscode-2015-06-19-08-23-26.tar.gz
--exclude='var/opt/opscode/postgresql/9.2/data' -C /

c) Start the postgresql service:

$ chef-server-ctl start postgresql

d) Restore the PostgreSQL database:

    su - opscode-pgsql

    gunzip -c /tmp/postgresql-dump-2015-06-19-08-23-26.gz |

/opt/opscode/embedded/bin/psql -U "opscode-pgsql" -d postgres

    Ignore the following error messages:
        ERROR: current user cannot be dropped
        ERROR: role "opscode-pgsql" already exists

e) Start the server:

$ chef-server-ctl start

Now when I try to login with the user which was existing on my Source
chef-server, I am not able to login

When I try to create a new-user, see the beloww logs:

[root@chefserverbackup vagrant]# chef-server-ctl user-create takedump
Test Test test@dump.com <javascript:_e(%7B%7D,'cvml','test@dump.com');>
test@1234 --filename test_chef.key
ERROR: Failed to authenticate to https://127.0.0.1:443 as pivotal with
key /etc/opscode/pivotal.pem
Response: An error occurred while trying to find 'pivotal'. Please
contact support.
[root@chefserverbackup vagrant]# chef-server-ctl user-list
ERROR: Failed to authenticate to https://127.0.0.1:443 as pivotal with
key /etc/opscode/pivotal.pem
Response: An error occurred while trying to find 'pivotal'. Please
contact support

Thanks,
Chandan

--
Thanks and Regards,
Chandan

Hello Chandan,

Try this one here:

$ knife backup export -D /backup/chef/timestamp

To restore, knife backup restore

Info: GitHub - mdxp/knife-backup: knife plugin to help backup and restore a chef server.

Best,

On Tue, Jun 23, 2015 at 1:30 AM, Chandan Maheshwari <cmaheshwari16@gmail.com

wrote:

Hi,

Can anyone help here. Aim is to backup and restore chef server data.
Approach and issue i am getting is explained in my previous mail.

Any input is much appreciated

On Sunday, June 21, 2015, Chandan Maheshwari cmaheshwari16@gmail.com
wrote:

Hi All,

My Source and Target chef server version is 12.0.5
("chef-server-core-12.0.5-1.el6.x86_64.rpm").

2 Scenarios:

First Scenorios1) Setup target chef-server.
After setting up created user:

[root@chefserverbackup vagrant]# chef-server-ctl user-create takedump
Test Test test@dump.com test@1234 --filename test_chef.key

User is created.

*Second Scenario:*1) I took dump from source chef-server. [I followed the below steps from link : Backup and Restore a Standalone or Frontend install]

a) Make a postgres export using the following commands:

export THEDATE=`date '+%Y-%m-%d-%H-%M-%S'`
sudo -E -u opscode-pgsql bash
/opt/opscode/embedded/bin/pg_dumpall -c | gzip --fast >

/tmp/postgresql-dump-$THEDATE.gz

b) Synchronize to make sure that all of the data is present on-disk:

sync

c) Backup the /etc/opscode and /var/opt/opscode directories and include
the postgres export file as root

tar cvfzp var-opt-opscode-$THEDATE.tar.gz /etc/opscode /var/opt/opscode /tmp/postgresql-dump-$THEDATE.gz

2) Restoring on Target server: [setup target chef-server]

a) Stop the server:

$ chef-server-ctl stop

b) Restore the previously backed-up files to the following locations:
/etc/opscode
/var/opt/opscode

by using the following command, which will exclude PostgreSQL files:

tar xvfzp /vagrant/var-opt-opscode-2015-06-19-08-23-26.tar.gz
--exclude='var/opt/opscode/postgresql/9.2/data' -C /

c) Start the postgresql service:

$ chef-server-ctl start postgresql

d) Restore the PostgreSQL database:

    su - opscode-pgsql

    gunzip -c /tmp/postgresql-dump-2015-06-19-08-23-26.gz |

/opt/opscode/embedded/bin/psql -U "opscode-pgsql" -d postgres

    Ignore the following error messages:
        ERROR: current user cannot be dropped
        ERROR: role "opscode-pgsql" already exists

e) Start the server:

$ chef-server-ctl start

Now when I try to login with the user which was existing on my Source
chef-server, I am not able to login

When I try to create a new-user, see the beloww logs:

[root@chefserverbackup vagrant]# chef-server-ctl user-create takedump
Test Test test@dump.com test@1234 --filename test_chef.key
ERROR: Failed to authenticate to https://127.0.0.1:443 as pivotal with
key /etc/opscode/pivotal.pem
Response: An error occurred while trying to find 'pivotal'. Please
contact support.
[root@chefserverbackup vagrant]# chef-server-ctl user-list
ERROR: Failed to authenticate to https://127.0.0.1:443 as pivotal with
key /etc/opscode/pivotal.pem
Response: An error occurred while trying to find 'pivotal'. Please
contact support

Thanks,
Chandan

--
Thanks and Regards,
Chandan

--
-- Tiago Cruz