Skip to content

Commit

Permalink
add check for data directory not existing to create-new-volume
Browse files Browse the repository at this point in the history
  • Loading branch information
s4ke committed Jan 15, 2023
1 parent 01d7637 commit dc41765
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ services:
sudo -u postgres /usr/lib/postgresql/15/bin/pg_ctl -D "/var/lib/postgresql/data" -m fast -w stop
}
mkdir -p /var/lib/postgresql/data
if [ -d /var/lib/postgresql/data ]; then
# the directory exists
if [ "$$(ls -A /var/lib/postgresql/data)" ]; then
echo "/var/lib/postgresql/data is not empty, will not run migration..."
exit 1
fi
else
mkdir -p /var/lib/postgresql/data
fi
chown -R 999:999 /var/lib/postgresql
cp -a -T /original_volume/ /var/lib/postgresql/data
ls -la /var/lib/postgresql/data
Expand Down

0 comments on commit dc41765

Please sign in to comment.