- [Show page]
- [Old revisions]
- [[unknown link type]]
- []
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
linux:debian:postgres:start [2010/03/10 20:24] admin |
linux:debian:postgres:start [2014/07/31 14:27] (current) kotrlik [Migrating from one server to another] |
||
---|---|---|---|
Line 139: | Line 139: | ||
* [[http://stackoverflow.com/questions/1237725/how-to-copy-postgres-database-to-another-server]] | * [[http://stackoverflow.com/questions/1237725/how-to-copy-postgres-database-to-another-server]] | ||
+ | |||
+ | Verze pro scripty | ||
+ | |||
+ | pgdump -U user -h localhost dbname | bzip2 > dbname.sql.bz | ||
+ | |||
+ | Pokud se prikaz vola v cronu pod rootem, je nutne vnutit postgresu heslo na uzivatele, krery ma k dumpovane db pristup (byt by to byl postgres). To se nastavuje v souboru /root/.pgpass a to ve tvaru hostname:port:database:username:password, tzn. *:*:*:postgres:passwd . | ||
+ | Pozor, sooubor musi mit prava 0600. jinak jej dump ignoruje! | ||
+ | |||
+ | |||
+ | Pokud narazite na chyby s LOCK relation, je treba zmenit uzivatele co dumpuje, nebo ptidat tomu soucasnemu spousta GRANT SELECT, nebo z nej udelat superusera. | ||
+ | |||
+ | ================= Mazani foreign keys ======================= | ||
+ | Nekdy se trochu nestatne stane, ze potrebujete smazat neco, co ma foreign key na tabulku, ktera ho ma na to, co chcete smazat. Takze Vam jedno nedovoli smazat druhe kvlu zavislosti a stejne tak naopak. Na to existuje hezky tricek, kdy kontrolu zavislosti nechate az na konec, kdy je vse smazane a tudiz ok :) | ||
+ | |||
+ | BEGIN TRANSACTION DEFERRABLE; | ||
+ | DELETE FROM a WHERE id='666'; | ||
+ | DELETE FROM b WHERE di='999'; | ||
+ | COMMIT; | ||
linux/debian/postgres/start.1268249066.txt.gz · Last modified: 2014/07/30 12:00 (external edit)