title: What is the best way to archive a postgres database?
body: <p>Here are the details:</p>
  
  <p>The database has to be archived such that records older than 6 months can be copied to a new database and deleted from the main(production) database. The complexity here will be to copy all rows in all tables which have reference each other. After that, these copied rows from some of the tables (which are really huge and whose data is no more needed) will be deleted. </p>
  
  <p>The postgres database is an Amazon RDS instance. </p>
  
  <p>What is the best way to achieve this? </p>
  
  <p>I was thinking either a Springboot application </p>
  
  <p>OR </p>
  
  <p>Have postgresql.conf invoke a shell script which invokes a sql batch. 
  For the second approach, I am not sure how to edit a amazon RDS postgresql.conf file and where to specify the shell script. Where would be the sql batch written? This is a little new to me, appreciate any pointers. </p>