mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-09 14:32:57 +00:00
## Problem See #2592 ## Summary of changes Compresses the results of initdb into a .tar.zst file and uploads them to S3, to enable usage in recovery from lsn. Generations should not be involved I think because we do this only once at the very beginning of a timeline. --------- Co-authored-by: Joonas Koivunen <joonas@neon.tech>
22 lines
863 B
Bash
Executable File
22 lines
863 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# like restore_from_wal.sh, but takes existing initdb.tar.zst
|
|
|
|
set -euxo pipefail
|
|
|
|
PG_BIN=$1
|
|
WAL_PATH=$2
|
|
DATA_DIR=$3
|
|
PORT=$4
|
|
echo "port=$PORT" >> "$DATA_DIR"/postgresql.conf
|
|
echo "shared_preload_libraries='\$libdir/neon_rmgr.so'" >> "$DATA_DIR"/postgresql.conf
|
|
REDO_POS=0x$("$PG_BIN"/pg_controldata -D "$DATA_DIR" | grep -F "REDO location"| cut -c 42-)
|
|
declare -i WAL_SIZE=$REDO_POS+114
|
|
"$PG_BIN"/pg_ctl -D "$DATA_DIR" -l "$DATA_DIR/logfile.log" start
|
|
"$PG_BIN"/pg_ctl -D "$DATA_DIR" -l "$DATA_DIR/logfile.log" stop -m immediate
|
|
cp "$DATA_DIR"/pg_wal/000000010000000000000001 .
|
|
cp "$WAL_PATH"/* "$DATA_DIR"/pg_wal/
|
|
for partial in "$DATA_DIR"/pg_wal/*.partial ; do mv "$partial" "${partial%.partial}" ; done
|
|
dd if=000000010000000000000001 of="$DATA_DIR"/pg_wal/000000010000000000000001 bs=$WAL_SIZE count=1 conv=notrunc
|
|
rm -f 000000010000000000000001
|