- 
                Notifications
    
You must be signed in to change notification settings  - Fork 127
 
[WIP] Add pg_dump/restore migration docs #2648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Closed
      
      
    
  
     Closed
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            2 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
This file was deleted.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| --- | ||
| title: Migrate from Postgres using pg_dump and pg_restore | ||
| excerpt: Migrate a entire database with native PostgreSQL commands | ||
| products: [cloud, self_hosted] | ||
| keywords: [dump, restore] | ||
| tags: [recovery, pg_dump, pg_restore] | ||
| --- | ||
| 
     | 
||
| import ConsiderCloud from "versionContent/_partials/_consider-cloud.mdx"; | ||
| 
     | 
||
| # Migrate to Timescale Cloud using `pg_dump` and `pg_restore` | ||
| 
     | 
||
| You can backup and restore an entire database using | ||
| the native PostgreSQL [`pg_dump`][pg_dump] and [`pg_restore`][pg_restore] | ||
| commands. | ||
| 
     | 
||
| ## Back up your entire database | ||
| 
     | 
||
| You can perform a backup using the `pg_dump` command at the command prompt. For | ||
| example, to backup a database named `tsdb`: | ||
| 
     | 
||
| ```bash | ||
| pg_dump -Fc -f tsdb.bak tsdb | ||
| ``` | ||
| 
     | 
||
| To backup a database named `tsdb` hosted on a remote server: | ||
| 
     | 
||
| ```bash | ||
| pg_dump -h <REMOTE_HOST> -p 55555 -U tsdbadmin -Fc -f tsdb.bak tsdb | ||
| ``` | ||
| 
     | 
||
| You might see some errors when running `pg_dump`. To learn if they can be safely | ||
| ignored, see the [troubleshooting section][troubleshooting]. | ||
| 
     | 
||
| ## Restore your entire database from backup | ||
| 
     | 
||
| <Procedure> | ||
| 
     | 
||
| ### Restoring an entire database from backup | ||
| 
     | 
||
| 1. Run [timescaledb_pre_restore][timescaledb_pre_restore] to put your database | ||
| in the right state for restoring: | ||
| 
     | 
||
| ```sql | ||
| SELECT timescaledb_pre_restore(); | ||
| ``` | ||
| 
     | 
||
| 1. Restore the database: | ||
| 
     | 
||
| ```sql | ||
| \! pg_restore -Fc -d tsdb tsdb.bak | ||
| 
     | 
||
| 1. Run [`timescaledb_post_restore`][timescaledb_post_restore] to return your | ||
| database to normal operations: | ||
| 
     | 
||
| ```sql | ||
| SELECT timescaledb_post_restore(); | ||
| ``` | ||
| 
     | 
||
| </Procedure> | ||
| 
     | 
||
| [parallel importer]: https://github.com/timescale/timescaledb-parallel-copy | ||
| [pg_dump]: https://www.postgresql.org/docs/current/static/app-pgdump.html | ||
| [pg_restore]: https://www.postgresql.org/docs/current/static/app-pgrestore.html | ||
| [timescaledb_pre_restore]: /api/:currentVersion:/administration/timescaledb_pre_restore/ | ||
| [timescaledb_post_restore]: /api/:currentVersion:/administration/timescaledb_post_restore/ | ||
| [timescaledb-upgrade]: /self-hosted/:currentVersion:/upgrades/ | ||
| [troubleshooting]: /self-hosted/:currentVersion:/troubleshooting/#versions-are-mismatched-when-dumping-and-restoring-a-database | ||
| [postgres-docs]: https://www.postgresql.org/docs/current/app-pg-dumpall.html | ||
        
          
          
            13 changes: 13 additions & 0 deletions
          
          13 
        
  use-timescale/migration/timescaledb-pg-dump-and-restore.md
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| title: Migrate from TimescaleDB to Timescale Cloud using pg_dump and pg_restore | ||
| excerpt: Migrate a hypertable or entire database with native PostgreSQL commands | ||
| products: [cloud, self_hosted] | ||
| keywords: [backups, restore] | ||
| tags: [recovery, logical backup, pg_dump, pg_restore] | ||
| --- | ||
| 
     | 
||
| import ConsiderCloud from "versionContent/_partials/_consider-cloud.mdx"; | ||
| 
     | 
||
| # Migration using `pg_dump` and `pg_restore` | ||
| 
     | 
||
| 
     | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are recommending customers to use the flags
--no-tablespaces --no-owner --no-privilegesto prevent permission errors.