updated playbooks with backup and restore
diff --git a/README.md b/README.md
index 3ebede3..d89512f 100644
--- a/README.md
+++ b/README.md
@@ -1,31 +1,44 @@
-Role Name
-=========
+Apigee OPDK Restore
+===================
-A brief description of the role goes here.
+This role performs a restore using the apigee-service utility. This role
+requires that you indicate which backup to restore.
Requirements
------------
-Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
+It is expected that the apigee-service utility was used as described at
+[How to Perform a Backup](http://docs.apigee.com/private-cloud/latest/how-perform-backup).
Role Variables
--------------
-A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
+#### backup_time
+
+This variable contains the date and time of the backup that should be
+restored. The naming convention of the backup files is explained at
+[How to Perform a Backup](http://docs.apigee.com/private-cloud/latest/how-perform-backup).
+This variable expects the date and time value to be set using the pattern:
+
+ backup_time: (year).(month).(day),(hour).(min).(seconds)
+
+#### component_name
+
+This variable expects the name of an apigee component to be restored.
Dependencies
------------
-A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
+- apigee-opdk-setup-default-settings
Example Playbook
----------------
-Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
+Example usage in a playbook:
- - hosts: servers
+ - hosts: pg
roles:
- - { role: username.rolename, x: 42 }
+ - { role: apigee-opdk-restore, component_name: apigee-cassandra, backup_time: 2016.10.27,08.45.35 }
License
-------
@@ -35,4 +48,4 @@
Author Information
------------------
-An optional section for the role authors to include contact information, or a website (HTML is not allowed).
+Carlos Frias
diff --git a/tasks/backup-non-postgres-component.yml b/tasks/backup-non-postgres-component.yml
deleted file mode 100644
index 2771cad..0000000
--- a/tasks/backup-non-postgres-component.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-- name: Stop component {{ component_profile }}
- shell: '{{ apigee_service }} {{ component_profile }} stop'
-
-- name: Backup component {{ component_profile }}
- shell: '{{ apigee_service }} {{ component_profile }} restore backup-{{ backup_time }}.tar.gz'
-
-- name: Start component {{ component_profile }}
- shell: '{{ apigee_service }} {{ component_profile }} start'
diff --git a/tasks/backup-postgres-component.yml b/tasks/backup-postgres-component.yml
deleted file mode 100644
index 7efc683..0000000
--- a/tasks/backup-postgres-component.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-- name: Stop component {{ component_profile }}
- shell: '{{ apigee_service }} {{ component_profile }} stop'
-
-- name: Backup component {{ component_profile }}
- shell: '{{ apigee_service }} {{ component_profile }} restore {{ backup_time }}.dump'
-
-- name: Start component {{ component_profile }}
- shell: '{{ apigee_service }} {{ component_profile }} start'
diff --git a/tasks/main.yml b/tasks/main.yml
index be235ff..108ea26 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,7 +1,7 @@
---
# tasks file for apigee-opdk-backup
-- include: backup-non-postgres-component.yml
- when: component_profile != 'apigee-postgresql'
+- include: restore-non-postgres-component.yml
+ when: component_name != 'apigee-postgresql'
-- include: backup-postgres-component.yml
- when: component_profile == 'apigee-postgresql'
+- include: restore-postgres-component.yml
+ when: component_name == 'apigee-postgresql'
diff --git a/tasks/restore-non-postgres-component.yml b/tasks/restore-non-postgres-component.yml
new file mode 100644
index 0000000..b64cf50
--- /dev/null
+++ b/tasks/restore-non-postgres-component.yml
@@ -0,0 +1,15 @@
+---
+- name: Stop component {{ component_name }}
+ shell: '{{ apigee_service }} {{ component_name }} stop'
+
+- name: Remove the {{ component_name }} data prior to restore
+ become: true
+ file:
+ path: '{{ apigee_installation_home }}/data/{{ component_name }}'
+ state: absent
+
+- name: Restore component {{ component_name }}
+ shell: '{{ apigee_service }} {{ component_name }} restore backup-{{ backup_time }}.tar.gz'
+
+- name: Start component {{ component_name }}
+ shell: '{{ apigee_service }} {{ component_name }} start'
diff --git a/tasks/restore-postgres-component.yml b/tasks/restore-postgres-component.yml
new file mode 100644
index 0000000..236b32d
--- /dev/null
+++ b/tasks/restore-postgres-component.yml
@@ -0,0 +1,6 @@
+---
+- name: Start component {{ component_name }}
+ shell: '{{ apigee_service }} {{ component_name }} start'
+
+- name: Restore component {{ component_name }}
+ shell: '{{ apigee_service }} {{ component_name }} restore {{ backup_time }}'