Get the most out of your Centmin Mod LEMP stack
Become a Member

tar -p parameter error

Discussion in 'System Administration' started by pamamolf, Oct 10, 2014.

  1. pamamolf

    pamamolf Well-Known Member

    2,724
    243
    63
    May 31, 2014
    Ratings:
    +434
    Local Time:
    7:45 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Hi

    When i try to backup using this:
    tar -zcfp /home/backup/forumfiles_$(/bin/date +%Y-%m-%d).tgz public

    i am getting this error:
    /home/backup/forumfiles_2014-10-10.tgz: Cannot stat: No such file or directory

    and when i remove the p from parameters is fine but i want to get backups using p (preserve permissions) :(
    Any ideas how can i fix this?

    Thanks
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    2:45 PM
    Nginx 1.13.x
    MariaDB 5.5
    order matters
    Code:
    tar -cpvzf
     
    • Like Like x 1
  3. pamamolf

    pamamolf Well-Known Member

    2,724
    243
    63
    May 31, 2014
    Ratings:
    +434
    Local Time:
    7:45 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Ok thanks :)
     
  4. pamamolf

    pamamolf Well-Known Member

    2,724
    243
    63
    May 31, 2014
    Ratings:
    +434
    Local Time:
    7:45 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Is there anyway to create a folder using the date (/bin/date +%d-%m-%Y) and add there all backups from databases and forum files?

    So i can get :

    /backup/22-10-2014/databases and files here from that day
    /backup/23-10-2014/databases and files here from that day


    #!/bin/bash
    # Edit the variables below
    DBNAME="name_db"
    DBUSER="user_db"
    DBPASSWD="123456789"
    BACKUPDIR="/backup"
    PUBLICFOLDER="/home/nginx/domains/mydomain.com"
    /usr/bin/mysqldump $DBNAME -u $DBUSER -p$DBPASSWD > $BACKUPDIR/database.sql
    cd $BACKUPDIR
    /bin/tar -zcf database_$(/bin/date +%d-%m-%Y).tgz database.sql
    cd $PUBLICFOLDER
    /bin/tar -cpvzf $BACKUPDIR/sitefiles_$(/bin/date +%d-%m-%Y).tgz public
    sleep 2
    rm $BACKUPDIR/database.sql

    How can i do this please?

    Thanks
     
  5. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    2:45 PM
    Nginx 1.13.x
    MariaDB 5.5
    Google has your answers as does reading links at Create a bash script | Centmin Mod Community within that thread

    hint make date a variable and append it to BACKUPDIR variable's value - you can check Centmin Mod's own code or /addons/*.sh files for clues ;)

    other members here are free to offer advice, but this is going beyond Centmin Mod's provided as policy for myself.
     
    • Like Like x 2
  6. pamamolf

    pamamolf Well-Known Member

    2,724
    243
    63
    May 31, 2014
    Ratings:
    +434
    Local Time:
    7:45 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Ok thanks i will try it :)
     
    Last edited: Oct 10, 2014
  7. pamamolf

    pamamolf Well-Known Member

    2,724
    243
    63
    May 31, 2014
    Ratings:
    +434
    Local Time:
    7:45 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Also in the net the most scripts start like:

    #/bin/bash
    and not like mine:
    #!/bin/bash
    is this a problem?
     
    Last edited: Oct 10, 2014
  8. pamamolf

    pamamolf Well-Known Member

    2,724
    243
    63
    May 31, 2014
    Ratings:
    +434
    Local Time:
    7:45 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    I found the answer for the above so ignore it :)
     
    Last edited: Oct 10, 2014
  9. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    2:45 PM
    Nginx 1.13.x
    MariaDB 5.5
    digitalocean vps for 4 hrs only costs US$0.007x4 = US$0.028 enough time for quite a bit of testing ;)
     
  10. pamamolf

    pamamolf Well-Known Member

    2,724
    243
    63
    May 31, 2014
    Ratings:
    +434
    Local Time:
    7:45 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Ok thanks :)

    Can you recommend me if i must use the sleep command in any other place to avoid any problems?

    Also is there any specific reason to use verbose on a bash script -v as you recommend me?

    tar -cpvzf

    Thanks
     
    Last edited: Oct 10, 2014