pgsql.init/pgdump.sh
authorAlan Knowles <alan@roojs.com>
Mon, 11 Nov 2013 15:05:02 +0000 (23:05 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 11 Nov 2013 15:05:02 +0000 (23:05 +0800)
pgsql.init/pgdump.sh

index 57f548f..444ca2f 100644 (file)
@@ -1,20 +1,25 @@
 #!/bin/bash
 
  
-for table in  `psql -Uadmin testxtuple -Atc  "SELECT nspname || '.' || c.relname FROM pg_class c LEFT JOIN pg_namespace N ON (N.oid =c.relnamespace) WHERE c.relkind = 'S';" | cut -d '|' -f1`
-do   
-   pg_dump -Uadmin  --disable-triggers testxtuple -Fp -t $table -a -f /tmp/pgdump/$table.sql;
-   one=`grep  SELECT /tmp/pgdump/$table.sql  | grep -v 1`
-   if [ "$one" != "" ]
-        then
-        rm /tmp/pgdump/$table.sql;
-   fi
-done
+#for table in  `psql -Uadmin testxtuple -Atc  "SELECT nspname || '.' || c.relname FROM pg_class c LEFT JOIN pg_namespace N ON (N.oid =c.relnamespace) WHERE c.relkind = 'S';" | cut -d '|' -f1`
+#do   
+#   pg_dump -Uadmin  --disable-triggers testxtuple -Fp -t $table -a -f /tmp/pgdump/$table.sql;
+#   one=`grep  SELECT /tmp/pgdump/$table.sql  | grep -v 1`
+#   if [ "$one" != "" ]
+#        then
+#        rm /tmp/pgdump/$table.sql;
+#   fi
+#done
 
 
 for table in `psql -Uadmin testxtuple -Atc "SELECT   nspname || '.' || relname,reltuples FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid =C.relnamespace) WHERE    nspname NOT IN ('pg_catalog', 'information_schema') AND  relkind='r' and reltuples != 0 ORDER BY reltuples DESC;" | cut -d '|' -f1`   
 do   
    pg_dump -Uadmin  --disable-triggers testxtuple -Fp -t $table -a -f /tmp/pgdump/$table.sql;
-   pg_dump -Uadmin  --disable-triggers testxtuple -Fp -t ${table}_${table}_id_seq -a -f /tmp/pgdump/${table}_${table}_id_seq.sql;
 
 done
+
+for table in `psql -Uadmin testxtuple -Atc "SELECT   nspname || '.' || relname || '_' || relname ,reltuples FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid =C.relnamespace) WHERE    nspname NOT IN ('pg_catalog', 'information_schema') AND  relkind='r' and reltuples != 0 ORDER BY reltuples DESC;" | cut -d '|' -f1`   
+do   
+   pg_dump -Uadmin  --disable-triggers testxtuple -Fp -t ${table}_id_seq -a -f /tmp/pgdump/${table}_id_seq.sql;
+
+done
\ No newline at end of file