<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=1919&amp;type=atom"/>
	<updated>2014-01-13T08:15:43Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=1919</id>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4969#p4969"/>
			<content type="html"><![CDATA[[quote=matchek]Jak zrobić backupy na dysk zewnętrzny, tak aby się robiły np o 3 w nocy ? i dodawały kolejne tak by trzymać backupy z 7 ostatnich dni.[/quote]


To robi backup gdzieś tam. 

root@panoramix2:/media/usb0# cat backup_postgresql
#!/usr/bin/env python
import os
import time

username = 'postgres'
defaultdb = 'postgres'
sysdb = 'system'
port = '5432'
backupdir='/var/backup/pgdb/'
date = time.strftime('%Y-%m-%d-%H-%M-%S')
get_db_names="psql -U%s -d%s -p%s --tuples-only -c '\l' | awk -F\| '{ print $1 }'|  sed -e '/^\ *$/d' | grep -E -v '(template0|template1^$)'" % (username, defaultdb, port)
def log(string):
    print time.strftime("%Y-%m-%d-%H-%M-%S", time.gmtime()) + ": " + str(string)
os.popen("pg_dumpall -p%s -g|gzip -9 -c >  %s/system.%s.gz" % (port, backupdir, date))
for base in os.popen(get_db_names).readlines():
	log("dump rozpoczety dla bazy:%s" % base)
        base = base.strip()
        fulldir = backupdir + base
        if not os.path.exists(fulldir):
                os.mkdir(fulldir)
        filename = "%s/%s-%s.sql" % (fulldir, base, date)
        os.popen("nice -n 19 pg_dump -C -F c -U%s -p%s %s | gzip -9 -c > %s.gz" % (username, port, base, filename))
	log("dump %s zakonczony" % base)
log("Backup zakonczony.")


To usuwa stare backupy.

bash-4.1$ cat /var/lib/pgsql/9.1/remove_old_backup.sh
#!/bin/bash
cd /var/backup/pgdb/
find . -mtime +1 | xargs rm -Rf
bash-4.1$]]></content>
			<author>
				<name><![CDATA[micromachine]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1704</uri>
			</author>
			<updated>2014-01-13T08:15:43Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4969#p4969</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4948#p4948"/>
			<content type="html"><![CDATA[został mam nadzieję tylko problem z [code] cp: cannot stat `/var/lib/postgresql/9.3/archive/00000001000000000000002E': No such file or directory [/code]]]></content>
			<author>
				<name><![CDATA[matchek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1687</uri>
			</author>
			<updated>2013-12-13T20:58:53Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4948#p4948</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4947#p4947"/>
			<content type="html"><![CDATA[Najlepiej przestać kombinować w pisanie własnych skryptów, bo sorry - poświęciliśmy 60 postów na to byś "postawił" replikację. To ile postów na to byś napisał działające skrypty backupujące?

Są gotowe narzędzia, wystarczy wpisać w google'a - choćby omnipitr, barman, wal-e. Każdy z nich (jak i postgres) ma dokumentację, gdzie jest opisane jak postawić. Jak będziesz miał [b]konkretny[/b] problem, to pisz - postaram się pomóc. Ale nie jestem w stanie wygrzebać czasu na tłumaczenie krok po kroku: jak skonfigurować ssh, jak zrobić klucz, jak wpisać hasło, jak zainstalować <xxx>. 

To nawet w większości nie są pytania o postgresa tylko o system operacyjny, linuksa, edytor tekstu.]]></content>
			<author>
				<name><![CDATA[depesz]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1564</uri>
			</author>
			<updated>2013-12-13T20:42:40Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4947#p4947</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4946#p4946"/>
			<content type="html"><![CDATA[Nie czeka. Jak cp się wywala, to pg się powinien przełączyć na replikację "streamującą". A jak się nie przełączy, to co jakiś czas będzie próbował ten plik odczytać.]]></content>
			<author>
				<name><![CDATA[depesz]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1564</uri>
			</author>
			<updated>2013-12-13T20:35:59Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4946#p4946</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4945#p4945"/>
			<content type="html"><![CDATA[Jak zrobić backupy na dysk zewnętrzny, tak aby się robiły np o 3 w nocy ? i dodawały kolejne tak by trzymać backupy z 7 ostatnich dni.]]></content>
			<author>
				<name><![CDATA[matchek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1687</uri>
			</author>
			<updated>2013-12-13T20:35:57Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4945#p4945</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4944#p4944"/>
			<content type="html"><![CDATA[on czeka na kolejny plik ? jak się pojawi ten, to będzie krzyczał ze nie ma innego pliku tak ?]]></content>
			<author>
				<name><![CDATA[matchek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1687</uri>
			</author>
			<updated>2013-12-13T20:34:30Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4944#p4944</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4943#p4943"/>
			<content type="html"><![CDATA[całkowicie ok.]]></content>
			<author>
				<name><![CDATA[depesz]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1564</uri>
			</author>
			<updated>2013-12-13T20:29:33Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4943#p4943</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4942#p4942"/>
			<content type="html"><![CDATA[a co z tym?
[code]cp: cannot stat `/var/lib/postgresql/9.3/archive/00000001000000000000002E': No such file or directory[/code]]]></content>
			<author>
				<name><![CDATA[matchek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1687</uri>
			</author>
			<updated>2013-12-13T20:28:14Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4942#p4942</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4941#p4941"/>
			<content type="html"><![CDATA[to doinstaluj. apt-get install postgresql-contrib, czy jakoś tak.]]></content>
			<author>
				<name><![CDATA[depesz]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1564</uri>
			</author>
			<updated>2013-12-13T20:21:14Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4941#p4941</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4940#p4940"/>
			<content type="html"><![CDATA[no właśnie nie mam :/]]></content>
			<author>
				<name><![CDATA[matchek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1687</uri>
			</author>
			<updated>2013-12-13T20:19:42Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4940#p4940</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4939#p4939"/>
			<content type="html"><![CDATA[[code]maciejdan@primary:~$ sudo -u postgres psql -c "CREATE TABLE fake_customers (name VARCHAR(32));"
[sudo] password for maciejdan:
CREATE TABLE
[/code]
[code]maciejdan@secondary:~$ sudo -u postgres psql -c "SELECT name FROM fake_customers;"
 name
------
(0 rows)
[/code]

a ten warrning mowi że nie mam archive cleanup

[code]maciejdan@secondary:~$ pg_archivecleanup
pg_archivecleanup: command not found
[/code]

ten archive cleanup jest potrzebny ?]]></content>
			<author>
				<name><![CDATA[matchek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1687</uri>
			</author>
			<updated>2013-12-13T20:08:28Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4939#p4939</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4938#p4938"/>
			<content type="html"><![CDATA[coś więcej jest (powyżej/poniżej)? Masz w ogóle pg_archivecleanup?]]></content>
			<author>
				<name><![CDATA[depesz]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1564</uri>
			</author>
			<updated>2013-12-13T20:08:26Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4938#p4938</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4937#p4937"/>
			<content type="html"><![CDATA[wykrakałeś warninga właśnie się pojawił
[code]2013-12-13 21:03:55 CET WARNING:  archive_cleanup_command "pg_archivecleanup /var/lib/postgresql/9.3/archive/ %r": return code 32512[/code]]]></content>
			<author>
				<name><![CDATA[matchek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1687</uri>
			</author>
			<updated>2013-12-13T20:06:46Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4937#p4937</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4936#p4936"/>
			<content type="html"><![CDATA[Olać.  To "LOG:". nie warning, nie error, nie fatal. replikacja działa?]]></content>
			<author>
				<name><![CDATA[depesz]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1564</uri>
			</author>
			<updated>2013-12-13T20:04:34Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4936#p4936</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: postgresql 9.3 problem z replikacją (segmenty WAL)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4935#p4935"/>
			<content type="html"><![CDATA[a co z tym ?
 [code]2013-12-13 20:58:55 CET LOG:  incomplete startup packet[/code] i
[code]cp: cannot stat `/var/lib/postgresql/9.3/archive/00000001000000000000002D': No such file or directory[/code]
mam to na primary i na secondary

[code]maciejdan@primary:~$ tail -f /var/log/postgresql/postgresql-9.3-main.log
2013-12-13 20:40:40 CET LOG:  incomplete startup packet
2013-12-13 20:40:48 CET LOG:  received fast shutdown request
2013-12-13 20:40:48 CET LOG:  aborting any active transactions
2013-12-13 20:40:48 CET LOG:  autovacuum launcher shutting down
2013-12-13 20:40:48 CET LOG:  shutting down
2013-12-13 20:40:48 CET LOG:  database system is shut down
2013-12-13 20:42:20 CET LOG:  database system was shut down at 2013-12-13 20:40:48 CET
2013-12-13 20:42:20 CET LOG:  database system is ready to accept connections
2013-12-13 20:42:20 CET LOG:  autovacuum launcher started
2013-12-13 20:42:20 CET LOG:  incomplete startup packet
[/code]

[code]maciejdan@secondary:~$ tail -f /var/log/postgresql/postgresql-9.3-main.log
2013-12-13 20:58:54 CET LOG:  database system was shut down in recovery at 2013-12-13 20:56:52 CET
2013-12-13 20:58:54 CET LOG:  entering standby mode
2013-12-13 20:58:54 CET LOG:  restored log file "00000001000000000000002C" from archive
2013-12-13 20:58:54 CET LOG:  redo starts at 0/2C000090
2013-12-13 20:58:54 CET LOG:  consistent recovery state reached at 0/2D000000
2013-12-13 20:58:54 CET LOG:  database system is ready to accept read only connections
cp: cannot stat `/var/lib/postgresql/9.3/archive/00000001000000000000002D': No such file or directory
2013-12-13 20:58:54 CET LOG:  invalid magic number 0000 in log segment 00000001000000000000002D, offset 0
2013-12-13 20:58:54 CET LOG:  started streaming WAL from primary at 0/2D000000 on timeline 1
2013-12-13 20:58:55 CET LOG:  incomplete startup packet
[/code]]]></content>
			<author>
				<name><![CDATA[matchek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1687</uri>
			</author>
			<updated>2013-12-13T20:02:11Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4935#p4935</id>
		</entry>
</feed>
