Results 1 to 7 of 7

Thread: Backups

  1. #1
    Join Date
    Mar 2015
    Posts
    4

    Unanswered: Backups

    I was tasked to create weekly and daily snapshot backups of the data.
    Since I just started working with Postgres, I found the option to use pg_dump for the backup.
    Unfortunately the server being used does not have any room left on the /var directory where I am running the backup. After I execute it, it runs out of space and stops halfway through. The database backup ran with pg_dump dbname > file.gz is over 7gb since i tried running it inside the /tmp directory and it also crashed. As an alternative, I tried using the opt/app directory you see below, since it has the most amount of data available but i can a permission denied message. Are there any alternatives to accomplish my task? Should i look into gaining permission to the /opt/app directory or the backup should not be stored there?

    Click image for larger version. 

Name:	forum.PNG 
Views:	4 
Size:	17.6 KB 
ID:	16210

    Would the pg_dump name > output serve as a full weekly backup, or the daily snapshot?


    Any help would be greatly appreciated.

  2. #2
    Join Date
    Oct 2010
    Location
    Orlando, FL
    Posts
    311
    Provided Answers: 1
    Do this:

    Code:
    mkdir /database
    chmod 775 /database
    Now backup your data into the /database folder:

    Code:
    pg_dump dbname > /database/backup.sql
    *FYI*
    It's very bad practice to write to / directory however in your case, I think you can justify it. Let me know if you need more help or if this doesn't work for you.

  3. #3
    Join Date
    Mar 2015
    Posts
    4
    Thank you for the suggestion.
    You proposed to write the backup to the root directory, but according to the output of df -h, root only shows 11GB available, while /OPT/APP contains more than 400. With that said, wouldn't it be better to store the backup into the /opt directory? I actually tried to do so, but got a permission error. I have sudo rights, but get the error regardless. Sorry for all the questions, I am new to linux and postgres so some of the questions might be very basic...

  4. #4
    Join Date
    Oct 2010
    Location
    Orlando, FL
    Posts
    311
    Provided Answers: 1
    Show me:

    Code:
    whoami;groups

  5. #5
    Join Date
    Mar 2015
    Posts
    4
    Quote Originally Posted by CarlosinFL View Post
    Show me:

    Code:
    whoami;groups
    it outputs two lines:
    my username
    my company

    it uses active directory for the users.

  6. #6
    Join Date
    Mar 2015
    Location
    Indonesia
    Posts
    3
    Quote Originally Posted by brito View Post
    Thank you for the suggestion.
    You proposed to write the backup to the root directory, but according to the output of df -h, root only shows 11GB available, while /OPT/APP contains more than 400. With that said, wouldn't it be better to store the backup into the /opt directory? I actually tried to do so, but got a permission error. I have sudo rights, but get the error regardless. Sorry for all the questions, I am new to linux and postgres so some of the questions might be very basic...
    from my opinion , you can make directory inside /opt/app

    Code:
    sudo mkdir /opt/app/backupfolder
    Code:
    cd /opt/app/
    and check current owner of that directory
    Code:
    ls -l
    then changing it's with you id/username
    Code:
    sudo chown -R yourid backupfolder
    Code:
    sudo chmod -R 755 backupfolder
    then you can create crontab for weekly or daily backup to that directory
    Code:
    crontab -e
    to see what current crontab running
    Code:
    crontab -l
    hope that will help

  7. #7
    Join Date
    Mar 2015
    Posts
    4
    Quote Originally Posted by r4lly99 View Post
    from my opinion , you can make directory inside /opt/app

    Code:
    sudo mkdir /opt/app/backupfolder
    Code:
    cd /opt/app/
    and check current owner of that directory
    Code:
    ls -l
    then changing it's with you id/username
    Code:
    sudo chown -R yourid backupfolder
    Code:
    sudo chmod -R 755 backupfolder
    then you can create crontab for weekly or daily backup to that directory
    Code:
    crontab -e
    to see what current crontab running
    Code:
    crontab -l
    hope that will help
    In addition to your suggestion, creating the crontab as root solved the problem for me.
    Thank you for the assistance.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •