How to Snapshot and Rollback a PostgreSQL Helm Release on OpenShift

[vc_row type=”in_container” full_screen_row_position=”middle” scene_position=”center” text_color=”dark” text_align=”left” overlay_strength=”0.3″ shape_divider_position=”bottom” bg_image_animation=”none”][vc_column column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_link_target=”_self” column_shadow=”none” column_border_radius=”none” width=”1/1″ tablet_width_inherit=”default” tablet_text_alignment=”default” phone_text_alignment=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” centered_text=”true” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/4″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][image_with_animation image_url=”88700″ alignment=”” animation=”Fade In” border_radius=”none” box_shadow=”none” max_width=”100%”][nectar_btn size=”large” open_new_tab=”true” button_style=”regular” button_color_2=”Accent-Color” icon_family=”none” url=”https://get.robin.io/” text=”ROBIN Storage Free Download”][/vc_column_inner][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”3/4″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]In this tutorial, we will create a snapshot of the PostgreSQL database that is deployed on OpenShift. We will then restore the database state using the roll back to a point-in-time snapshot feature.

Before you begin this tutorial, make sure you have installed ROBIN Storage on your existing OpenShift cluster, and your PostgreSQL database is deployed on OpenShift, has data loaded in it, and the Helm release is registered with ROBIN.[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]If you make a mistake, such as unintentionally deleting important data, you can simply undo it by restoring a snapshot. Snapshots allow you to restore the state of your application to a point-in-time.

ROBIN lets you snapshot not just the storage volumes (PVCs) but the entire database application including all its resources such as Pods, StatefulSets, PVCs, Services, ConfigMaps, etc. with a single command. To create a snapshot, run the following command.[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”padding-1-percent” column_padding_position=”all” background_color=”#cccccc” background_color_opacity=”0.5″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”1px” column_border_color=”#cccccc” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]

robin snapshot create snap9movies movies --desc "contains 9 movies" --wait

[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]Let us verify we have successfully created the snapshot.[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”padding-1-percent” column_padding_position=”all” background_color=”#cccccc” background_color_opacity=”0.5″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”1px” column_border_color=”#cccccc” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]

robin snapshot list --app movies

[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]You should see an output similar to this:[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][image_with_animation image_url=”88714″ alignment=”” animation=”Fade In” img_link_large=”yes” border_radius=”none” box_shadow=”none” max_width=”100%”][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]We now have a snapshot of our entire database with information of all 9 movies.

Rolling back to a point-in-time using snapshot

We have 9 rows in our “movies” table. To test the snapshot and rollback functionality, let’s simulate a user error by deleting one movie, “June 9″, from the “movies” table.[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”padding-1-percent” column_padding_position=”all” background_color=”#cccccc” background_color_opacity=”0.5″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”1px” column_border_color=”#cccccc” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]

PGPASSWORD="$POSTGRES_PASSWORD" psql -h $IP_ADDRESS -U postgres
-d testdb -c "DELETE from movies where title = 'June 9';"

[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]Let us verify the movie titled “June 9” has been deleted.[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”padding-1-percent” column_padding_position=”all” background_color=”#cccccc” background_color_opacity=”0.5″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”1px” column_border_color=”#cccccc” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]

PGPASSWORD="$POSTGRES_PASSWORD" psql -h $IP_ADDRESS -U postgres 
-d testdb -c "SELECT * from movies;"

[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]You should see the row with the movie “June 9″ does not exist in the table anymore.[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][image_with_animation image_url=”88715″ alignment=”” animation=”Fade In” img_link_large=”yes” border_radius=”none” box_shadow=”none” max_width=”100%”][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]Let’s run the following command to see the available snapshots:[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”padding-1-percent” column_padding_position=”all” background_color=”#cccccc” background_color_opacity=”0.5″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”1px” column_border_color=”#cccccc” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]

robin app info movies

[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]You should see an output similar to the following. Note the snapshot id, as we will use it in the next command.[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][image_with_animation image_url=”88716″ alignment=”” animation=”Fade In” img_link_large=”yes” border_radius=”none” box_shadow=”none” max_width=”100%”][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]Now, let’s roll back to the point where we had 9 movies, including “June 9”, using the snapshot id displayed above.[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”padding-1-percent” column_padding_position=”all” background_color=”#cccccc” background_color_opacity=”0.5″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”1px” column_border_color=”#cccccc” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]

robin app rollback movies Your_Snapshot_ID --wait

[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][image_with_animation image_url=”88717″ alignment=”” animation=”Fade In” img_link_large=”yes” border_radius=”none” box_shadow=”none” max_width=”100%”][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]To verify we have rolled back to 9 movies in the “movies” table, run the following command.[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”padding-1-percent” column_padding_position=”all” background_color=”#cccccc” background_color_opacity=”0.5″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”1px” column_border_color=”#cccccc” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]

PGPASSWORD="$POSTGRES_PASSWORD" psql -h $IP_ADDRESS
-U postgres -d testdb -c "SELECT * from movies;"

[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]You should see an output similar to the following:[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][image_with_animation image_url=”88706″ alignment=”” animation=”Fade In” img_link_large=”yes” border_radius=”none” box_shadow=”none” max_width=”100%”][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/1″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][vc_column_text]We have successfully rolled back to our original state with 9 movies!

This concludes the Snapshot PostgreSQL on OpenShift tutorial. We can also clone the entire PostgreSQL database to improve collaboration across Dev/Test/Ops teams.[/vc_column_text][/vc_column_inner][/vc_row_inner][vc_row_inner column_margin=”default” text_align=”left”][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/3″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][nectar_btn size=”large” open_new_tab=”true” button_style=”regular” button_color_2=”Accent-Color” icon_family=”none” url=”/blog/deploy-postgresql-on-openshift/” text=”Deploy PostgreSQL”][/vc_column_inner][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/3″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][nectar_btn size=”large” open_new_tab=”true” button_style=”regular” button_color_2=”Accent-Color” icon_family=”none” url=”/blog/clone-postgresql-helm-release-gke/” text=”Clone PostgreSQL”][/vc_column_inner][vc_column_inner column_padding=”no-extra-padding” column_padding_position=”all” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” width=”1/3″ tablet_width_inherit=”default” column_border_width=”none” column_border_style=”solid” bg_image_animation=”none”][nectar_btn size=”large” open_new_tab=”true” button_style=”regular” button_color_2=”Accent-Color” icon_family=”none” url=”/blog/backup-postgresql-openshift-aws-s3/” text=”Backup & Restore PostgreSQL”][/vc_column_inner][/vc_row_inner][/vc_column][/vc_row]

Recommended Posts