Results 1 to 5 of 5

Thread: How to schedule automatic backup?

  1. #1
    rogersugarsugar is offline Sugar Community Member
    Join Date
    Jun 2007
    Posts
    38

    Default How to schedule automatic backup?

    4.5.1e

    The subject line says it all, I think. I can do a manual backup, but I see no way to actually schedule one. I could create an external cron job, but I see no information on what the manual backup actually does, so I can duplicate it.

    (And, regarding the manual backup, I can only backup to the /tmp directory. Anywhere else, including a directory with exactly the same permissions as /tmp, with full 777 along the path, and SugarCRM complains:

    Backup directory does not exist, and could not be created.
    Backup directory exists, but is not writable.
    )

    Thanks.

  2. #2
    ptemplin7 is offline Sugar Community Member
    Join Date
    Jun 2007
    Location
    Puget Sound Washington
    Posts
    380

    Smile Re: How to schedule automatic backup?

    Create the cron job. Sugar backup is basically useless as it does NOT backup the database, a critical component.

    In the cron job use gzip or whatever to zip the entire crm folder in one file and put it somewhere. (I use a backup folder on the webserver /var/www/html/backup) In the crontab also use mysqldump to backup the database. (Use anohter tool if using a DB other than the default mysql.)

    Alternately you can use myphpadmin to do this as well.

    Here are some syntax for the mysqldump.

    $ mysqldump --opt -u [uname] -p[pass] [dbname] > [backupfile.sql]
    where:
    [uname] Your database username
    [pass] The password for your database (note there is no space between -p and the password)
    [dbname] The name of your database
    [backupfile.sql] The filename for your database backup
    [--opt] The mysqldump option
    For example, to backup a database named 'Tutorials' with the username 'root' and with no password to a file tut_backup.sql, you should accomplish this command:$ mysqldump -u root -p Tutorials > tut_backup.sql

    OR If your mysql database is very big, you might want to compress the output of mysqldump. Just use the mysql backup command below and pipe the output to gzip, then you will get the output as gzip file.
    $ mysqldump -u [uname] -p[pass] [dbname] | gzip -9 > [backupfile.sql.gz]

    Hope this helps,
    Paris

  3. #3
    AlexKh is offline Member
    Join Date
    Aug 2007
    Posts
    5

    Default Re: How to schedule automatic backup?

    Hello, rogersugarsugar!

    After you created the archive file, you may also take a tool like Apatar to schedule an automated backup. For instance, you can configure it to back up your files at FTP server, or WebDAV, or Buzzsaw, or Amazon S3 web hosting, or whatever.

    Hope this would help.

    ---
    Alex Khizhnyak
    Apatar Evangelist

  4. #4
    rogersugarsugar is offline Sugar Community Member
    Join Date
    Jun 2007
    Posts
    38

    Default Re: How to schedule automatic backup?

    My solution was to make it part of the nightly backup, run through cron.

    Just shut down the database and put all of sugarcrm into a save set, including the database.

    I keep 7 days of online backups of all data on the system, with copies on a separate drive, and burn a copy to DVD periodically, for offsite storage.

  5. #5
    nyaconis is offline Member
    Join Date
    Aug 2008
    Posts
    8

    Default Re: How to schedule automatic backup?

    do this:
    > crontab -e

    edit the following:
    [savedirectory] - change to where your user has write access
    [usernmae] - your mysql username with dump rights.
    [password] - the password to the username
    [databasename] - the db name in the mysql database list.

    * * * * * cd /sites/sugarce; php -f cron.php > /dev/null 2>&1
    01 00 * * * mysqldump --opt -u[username] -p[password] [databasename] > [savedirectory]/sugarce_backup_current.sql;mv [savedirectory]sugarce_backup_current.sql [savedirectory]/$(date +%m%d%Ysugarce_backup.sql);gzip -f [savedirectory]/$(date +%m%d%Ysugarce_backup.sql);
    45 00 * * * cp -rf [sugarcrm file path: /sites/sugar] [savedirectory]/sugarce;tar -cf [savedirectory]/sugarce.tar [savedirectory]/sugarce;rm -rf [savedirectory]/sugarce;gzip -f [savedirectory]/sugarce.tar; mv [savedirectory]/sugarce.tar.gz [savedirectory]/$(date +%m%d%Ysugarce_backup.tar.gz);

    save this.
    restart crond.

    here is an example:
    * * * * * cd /sites/sugarce; php -f cron.php > /dev/null 2>&1
    01 00 * * * mysqldump --opt -umyuser -pmypassword sugarcrm > /bak/db/sugarce/sugarce_backup_current.sql;mv /bak/db/sugarce/sugarce_backup_current.sql /bak/db/sugarce/$(date +%m%d%Ysugarce_backup.sql);gzip -f /bak/db/sugarce/$(date +%m%d%Ysugarce_backup.sql);
    45 00 * * * cp -rf /sites/sugarce /bak/apps/sugarce;tar -cf /bak/apps/sugarce.tar /bak/apps/sugarce;rm -rf /bak/apps/sugarce;gzip -f /bak/apps/sugarce.tar; mv /bak/apps/sugarce.tar.gz /bak/apps/$(date +%m%d%Ysugarce_backup.tar.gz);


    At midnight every morning, this will build a gziped backup of the sugar database and name it MMDDYYYY_sugarce_backup.sql.zip.
    At 12:45 every morning, this will build a tar gzipped copy of your entire sugar application directory and name it MMDDYYYY_sugarce_backup.tar.gz.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 2012-01-03, 04:54 PM
  2. Module Install Permissions Problems
    By brown_er in forum Help
    Replies: 8
    Last Post: 2007-03-02, 03:37 PM
  3. Automatic accept on meetings I schedule?
    By cenforsberg in forum Help
    Replies: 0
    Last Post: 2006-09-01, 11:56 AM
  4. Backup and restoration
    By Mag in forum Help
    Replies: 4
    Last Post: 2006-08-21, 06:42 PM
  5. Backup without compression
    By ginoc in forum Help
    Replies: 5
    Last Post: 2005-11-18, 01:19 AM

Bookmarks

Posting Permissions

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