gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] Restoring a database under Debian


From: Busser, Jim
Subject: Re: [Gnumed-devel] Restoring a database under Debian
Date: Sat, 24 Jan 2015 05:22:44 +0000

On 2015-01-23, at 5:01 PM, Jim Busser <address@hidden> wrote:

> However when I tried to restore from this inside Debian VM, the following 
> problems ...
> 
> - the roles file that I was presented to edit was empty, and
> - the script failed, claiming the database.sql file did not exist
> 
> despite that following the failure I could (as root) both see them and verify 
> that roles.sql is NOT empty.

i think I have solved it … (??)

>From the /tmp/ directory wherein the untarred backup files were sitting, I was 
>able to finish the restore beginning where the restore script failed … 

However even if the restore script would be adjusted to assign ownership of the 
untarred directory (and not just the sql) to postgres, I have the impression 
that the inability to read and edit the roles-sql file occurred upstream of any 
need for postgres to have any permissions.

# =========================

# declare appropriate variables
GM_PORT="5433"

# declare a few more, derived from where the script failed
pwd
LOG_BASE="/tmp/gnumed"
RESTORE="gm-restore_2015-01-23_18-59-06"
BACKUP="backup-gnumed_v20-GNUmed_Team-MacBook-2.local-2015-01-21-21-05-31"
cd "${LOG_BASE}/${RESTORE}/${BACKUP}"


# THIS SOLVED MY PROBLEM - grant ownership of the backup directory itself to 
postgres
cd ../
chown -c postgres:postgres $BACKUP

# now return to the previous directory …
cd $BACKUP

# … and re-run steps that the restore script had been unable to successfully 
complete

# edit roles -- uncomment the wanted ones
nano ${BACKUP}-roles.sql

# in case the following commands had not been earlier applied …
# make SQL readable and assign ownership to postgres
chmod -c +r *.sql
chown -c postgres *.sql

# set log for restoring roles, and restore roles
LOG="${LOG_BASE}/restoring-roles.log"
sudo -u postgres psql -e -E -p ${GM_PORT} -f ${BACKUP}-roles.sql &> ${LOG}
chmod 0666 ${LOG}

# set log for restoring database, and restore database
LOG="${LOG_BASE}/restoring-database.log"
sudo -u postgres psql -p ${GM_PORT} -f ${BACKUP}-database.sql &> ${LOG}
chmod 0666 ${LOG}

#sanity check … is the very rough size of this database anything like what we 
expect?
sudo -u postgres psql -p 5433 -d gnumed_v20 -U gm-dbo -c 'SELECT 
pg_size_pretty(pg_database_size(current_database()));'

--> returns 298 MB … yes !! (the sql file from which it was created was 283 Mb)

I think I am happy!

But I had trouble to open a gnumed client 1.5.2 from tarball in Debian … the 
subject of my next post.

-- Jim


reply via email to

[Prev in Thread] Current Thread [Next in Thread]