Comments (9)
We have a backup/mirror script for cstore tables. But it assumes that the database doesn't change while the mirror script is running...
Script to translate between cstore filenames and a readable form:
SELECT
(SELECT oid
FROM pg_database
WHERE datname = current_database()) AS dboid,
ftrelid,
nspname,
relname
FROM pg_foreign_table
JOIN pg_class ON pg_class.oid = ftrelid
JOIN pg_namespace ON pg_namespace.oid = relnamespace;
Using this query, it's basically
- dump database
- copy cstore files to a temp dir with "readable" names
- rsync pg_dump + cstore
- restore tables
- mv readable cstore names to the right destination
[... pg_dump ...]
echo "Copying cstore files to tempdir..."
${ssh} ${production_host} "rm -rvf \"${dest_dir}/cstore_fdw/\""
${ssh} ${production_host} "mkdir -pv \"${dest_dir}/cstore_fdw/\""
${ssh} ${production_host} "cat /bi/mirror/get-cstore-tables.sql | ${psql} --user=dwh --tuples-only --no-align --field-separator=' ' --quiet ${production_database} | awk '{print \"cp -v {{pillar['pg-data-dir']}}/cstore_fdw/\"\$1\"/\"\$2\" ${dest_dir}/cstore_fdw/\"\$3\".\"\$4\";\ncp -v {{pillar['pg-data-dir']}}/cstore_fdw/\"\$1\"/\"\$2\".footer ${dest_dir}/cstore_fdw/\"\$3\".\"\$4\".footer\"}' | bash"
${ssh} ${production_host} "chmod -R 755 \"${dest_dir}/cstore_fdw/\""
[...]
echo "rsync cstore files to destination..."
${ssh} ${dest_host} "rm -rvf \"${dest_dir}/cstore_fdw/\""
${ssh} ${dest_host} "mkdir -pv \"${dest_dir}/cstore_fdw/\""
${ssh} ${dest_host} "rsync -av --delete ${production_host}:${dest_dir}/cstore_fdw/ ${dest_dir}/cstore_fdw/"
${ssh} ${dest_host} "chmod -R 755 ${dest_dir}/cstore_fdw"
[...]
[... pg_restore ...]
echo "Restoring cstore files from tempdir..."
${ssh} ${dest_host} "cat /bi/mirror/get-cstore-tables.sql | ${psql} --tuples-only --no-align --field-separator=' ' --quiet ${dest_tmp_db} | awk '{print \"cp -v ${dest_dir}/cstore_fdw/\"\$3\".\"\$4\" {{pillar['pg-data-dir']}}/cstore_fdw/\"\$1\"/\"\$2\";\ncp -v ${dest_dir}/cstore_fdw/\"\$3\".\"\$4\".footer {{pillar['pg-data-dir']}}/cstore_fdw/\"\$1\"/\"\$2\".footer\"}' | bash"
from cstore_fdw.
- I was thinking as an initial method, in the document we can tell users that they can use pg_dump (to dump the DDL commands) + COPY (SELECT * FROM ...) TO 'backupfile'. We can also implement COPY TO to make this a bit easier.
- If automatically managed files are inside PGDATA, pg_basebackup should back them up.
- For future, should we provide a script which users can use for backing up cstore tables?
from cstore_fdw.
Yeah, a script would be nice.
I'm also thinking that scripting backup-by-copying-table-files is a desirable approach for cstore. If you're doing COPY TO, then you're uncompressing the data in order to recompress it.
from cstore_fdw.
I added this to the list of features to be added in v1.3. v1.3 should be released sometime in the 1st quarter of 2015.
from cstore_fdw.
postponed to later release
from cstore_fdw.
So I assume we can't use pg_dump to create backups of the cstore files?
from cstore_fdw.
@Dezzsoke correct, you cannot.
from cstore_fdw.
FYI: if you install CStore files to the default location, the pg_basebackup binary backup will back them up. It's only pg_dump which will not.
from cstore_fdw.
FYI: when working with partitioned tables you want to use SELECT * FROM ONLY table. Otherwise you'd dump the data from the table twice if you copy it out from both the master and the partitions. (If you managed to do this you can do a TRUNCATE ONLY to drop out the data you don't need.
from cstore_fdw.
Related Issues (20)
- select count(1) from table where datecolum = '2020-02-01' slow HOT 4
- Missing dependencies in makefile targets
- Cant ./configure in CentOS 07
- How to make use of parallelization with cstore_fdw? HOT 2
- Tests not running on Travis, and missing CircleCI configs
- Support for Heroku Postgres / Citus Data addon? HOT 1
- Is cstore_fdw still supported by developers? HOT 3
- segfault during copy into foreign table HOT 2
- hll build error against v13 HOT 5
- Does cstore_fdw Support Parallel COPY into the Same Table?
- Integer overflow in cstore_clean_table_resources()
- How to insert load / into cstore foreign tables in order HOT 1
- Impact of number of partitions on cstore tables
- Skip indexes are not in use HOT 2
- make installcheck failed, "ERROR: could not open file ... for writing: Permission denied" HOT 1
- Support for PostgreSQL15 HOT 1
- v1.7.0 download files does not support PostgreSQL 13 HOT 1
- 目录不存在
- Unable to upgrade from cstore_fdw to citus
- pg14 is support?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cstore_fdw.