Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by mail.postgresql.org (8.11.3/8.11.1) with ESMTP id f2K6YvN50938 for ; Tue, 20 Mar 2001 01:34:57 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.1/8.11.1) with ESMTP id f2K6YTt10055; Tue, 20 Mar 2001 01:34:29 -0500 (EST) To: "Jay Hodges" cc: pgsql-admin@postgresql.org Subject: Re: Moving databases In-reply-to: <007501c0b0f8$39eec060$3d6efea9@jh> References: <007501c0b0f8$39eec060$3d6efea9@jh> Comments: In-reply-to "Jay Hodges" message dated "Mon, 19 Mar 2001 22:42:52 -0600" Date: Tue, 20 Mar 2001 01:34:28 -0500 Message-ID: <10052.985070068@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200103/149 X-Sequence-Number: 997 "Jay Hodges" writes: > Now that my database is becoming quite large, it has outgrown the /var/ par= > ition and I would like to move at least one database to /usr partition, or = > to a NFS. > can this be done easily, and if so, what would be the procedure to move the= > files with no losses (all databases are currently active on the Internet t= > o the public, but downtime is acceptable for moving them) As long as you can afford downtime, it's not too tough to move a specific database to another partition: 1. Shutdown database (stop postmaster). 2. Move target database to new location (tar and untar, or cp -r -p should do). You want to transfer the whole subdirectory $PGDATA/base/yourdb/ to /some/place/else. 3. Make a symlink at $PGDATA/base/yourdb pointing to /some/place/else. 4. Restart postmaster, et voila. (Or, if you want to move the whole installation to a larger partition, just copy the whole $PGDATA tree, and adjust your postmaster start script to supply the new PGDATA location.) This is of course a tad ungraceful, but it's plenty effective as long as your space-management needs can be met by shifting whole databases. There are discussions in the archives about moving individual tables around via symlinks, but that's a lot more tedious to maintain. One thing to keep in mind is that a dump/restore will not preserve the symlink structures; you should keep notes so that you can manually reconstruct the layout if necessary. Better space management tools are on the TODO list, but that's where things stand for now. regards, tom lane PS: keeping a database on an NFS server is NOT recommended --- see past discussions in the archives, most recently in pgsql-general around 9-Feb.