The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Manually creating tar.gz files from shell

Discussion in 'Data Protection' started by jpmohr, Sep 29, 2008.

  1. jpmohr

    jpmohr Member

    Joined:
    Jan 25, 2008
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    I want to be able to login to my server as root (via SSH), and run a command to backup a particular client's home folder (without having to go into cpanel). The reason being is that I want to backup several different clients, but don't want to have to keep switching back and forth to cpanel's "full backup" page.

    FYI: I do not have cpbackup enabled on my server.

    I was going to try something like tar -zcvf file.tar.gz /home/client
    But the resulting file is actually a different size than if I do the same backup via cpanel's full backup link (on the cpanel Web page).

    I don't know a lot about tar, etc... is that not the correct method?
    I need to know that if I restore the backups (via cpanel restore) that permissions will be ok, etc.

    Basically, I would love to know exactly how cpanel creates the backup files so I can do it via shell.

    Thanks,
    Jim.
     
  2. jayh38

    jayh38 Well-Known Member

    Joined:
    Mar 3, 2006
    Messages:
    1,215
    Likes Received:
    0
    Trophy Points:
    36
    Your manual backup does not contain the users mysql and other files needed for restoring a full backup.

    Is there any reason you are not wanting to run the cpanel backup? Its a difficult task to manually create a script that does what the backup does. If you are just worried about user files then the /home/client method is fine.
     
  3. jpmohr

    jpmohr Member

    Joined:
    Jan 25, 2008
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    I have cpanel backup disabled because my VPS runs its own backup. I am wanting to copy the individual cpanel backup (tar.gz) to keep an "active" copy locally (which I burn to DVD). If my only solution is to login to cpanel and do a "full backup", then I guess that's what I will have to do. I was just hoping to make it easier...

    Right now, I login to WHM, click the first account I want. I go to cpanel full backup link (copying the URL), and allow it to create the full backup. I then click the next account I want in WHM and paste the copied URL (so I don't have to go through all the cpanel pages again). It creates the tar.gz files I want. I then go to the shell and type "mv /home/client/*.gz ." to put it in the current "common" folder. Chown the tar.gz to my current user to download them under one FTP account.........

    - Jim.
     
  4. jayh38

    jayh38 Well-Known Member

    Joined:
    Mar 3, 2006
    Messages:
    1,215
    Likes Received:
    0
    Trophy Points:
    36
    I see. Then I would recommend setting an ftp server at home and then use the cpanel backup to log into and create the backups to the remote ftp server, which would be your local machine.

    No wasted time downloading, going through accounts, etc etc. Nothing is stored on the server side so no excess room taken or integrated into your vz image.

    All you need to do is keep your home ftp server online during its backup schedule. If thats not convenient, then simply setup the ftp backup system as mentioned and then run /scripts/cpbackup --force and that should start the backup to the remote ftp on demand.

    Good luck..
     
  5. boby

    boby Registered

    Joined:
    Aug 29, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    You can make a backup from SSH using the following command :

    /scripts/pkgacct username

    This will create a full cpmove backup of respective user account which will be stored in /home.

    You will have copy of backup as
    cpmove-username.tar.gz



    You can also restore by using following command :

    /scripts/restorepkg username

    This command will automatically restore your cpmove-username.tar.gz backup.
    Prior to restore, make sure you have the copy of backup as cpmove-username.tar.gz in /home.


    Hope this helps.

    Regards,
    Boby
     
  6. brianjking

    brianjking Active Member

    Joined:
    Sep 15, 2009
    Messages:
    35
    Likes Received:
    1
    Trophy Points:
    6
    Location:
    Chicago, IL
    cPanel Access Level:
    Root Administrator
    Twitter:
    Local backup via SFTP or SCP - AUTOMATED

    Anyone have a script that does this? I'd like it to run as a crontab, backup all MySQL databases, all user accounts, and have them be restorable to cPanel, and then copied/downloaded to my local machine via SCP or SFTP so I can burn to a DVD & Store on a RAID 1 hard disk.

    Please help! Thanks! :)
     
  7. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    If I understand you correctly, you want to extend the pkgacct functions
    to be able to backup all accounts instead of just single accounts?
    Code:
    #!/bin/bash
    IFS="$"
    
    cd /home
    
    ls /var/cpanel/users | grep -v "root\|mysql\|nobody" | while read CPUSER; do
       /scripts/pkgacct ${CPUSER}
    done
    
    ##### INSERT YOUR FTP TRANSFER OR MOVE COMMANDS HERE 
    
    FYI: The same thing can be accomplished directly from WHM if you only want to backup and FTP the backups!
     
    #7 Spiral, Sep 15, 2009
    Last edited: Sep 15, 2009
Loading...

Share This Page