Last active
August 29, 2015 19:42
-
-
Save karenc/9e6855dc77d7c425cabb to your computer and use it in GitHub Desktop.
Replaced by cnxarchive_db.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$#" -ne 2 ] | |
then | |
echo "Usage: $0 db_user db_name" | |
exit 1 | |
fi | |
DB_USER=$1 | |
DB_NAME=$2 | |
pg_dump -U $DB_USER --exclude-table-data=files --exclude-table-data=module_files $DB_NAME >cnxarchive_dump_without_files.sql | |
cat <<EOF | psql -U $DB_USER $DB_NAME | |
\\copy ( SELECT f.* FROM files f JOIN module_files mf ON f.fileid = mf.fileid WHERE mf.filename IN ('index.cnxml', 'index.cnxml.html', 'index_auto_generated.cnxml') ) TO 'cnxarchive_index_files.txt' | |
\\copy ( SELECT * FROM module_files WHERE filename IN ('index.cnxml', 'index.cnxml.html', 'index_auto_generated.cnxml') ) TO 'cnxarchive_index_module_files.txt' | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment