Results 1 to 10 of 10

Thread: Howto? Backup things not in database

  1. #1
    SteveH is offline Junior Member
    Join Date
    Sep 2006
    Posts
    4

    Question Howto? Backup things not in database

    My regular nightly backup schedule dumps the database and places it on a remote machine. But my administrative users are customising forms and adding custom fields (via the user interface).

    I've heard mention that thses changes and the data in these fields is not in the database. What else do I need to back up to ensure these changes (and data) are not lost in the event of a catastrophe?

    I don't want to back up the entire sugarcrm directory unless that is unavoidable.

    oops,
    Debian Sarge (Testing),
    SugarCRM OS v4.5.0b
    php 4.4.4-8
    apache/2.2.3
    MySQL 14.12

    At the moment I'm thinking the cache and custom directories
    Last edited by SteveH; 2006-12-21 at 01:53 AM.

  2. #2
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: Howto? Backup things not in database

    Quote Originally Posted by SteveH

    I don't want to back up the entire sugarcrm directory unless that is unavoidable.

    At the moment I'm thinking the cache and custom directories
    You should just backup the entire sugarcrm folder. Not because it is unavoidable, but because it is the simplest and most reliable way.

    If instead you choose to only backup the absolute minimum, you'll also need to constantly verify that no other files in any other sub-directory have been modified, which is just additional administrative overhead. Say for example that I modify some of the HTML in the ../modules/Contacts/EditView.html file, unless you know about needing to include that file too, the backup wouldn't pick it up.

    What I've done in the past (on Linux) is setup a cron job that runs a shell script which in turn creates a tar ball of the sugarcrm directory and zips it. Because the vast majority of the files are text, it zips rather well and adds little overhead to the overall backup file size.
    Regards,

    Angel Magaña
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

  3. #3
    malcolmh's Avatar
    malcolmh is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Aug 2004
    Posts
    1,712

    Default Re: Howto? Backup things not in database

    Hi,

    to backup both the database and the sugar directory with the ability to backup to a FTP server, try looking at the free tool phpMyBackPro
    Cheers Malcolm

    Genius4U Limited - Ingenious simple IT solutions for you / Genial einfache IT Lösungen für Sie
    http://www.genius4u.com or http://www.genius4u.de

  4. #4
    SteveH is offline Junior Member
    Join Date
    Sep 2006
    Posts
    4

    Default Re: Howto? Backup things not in database

    Quote Originally Posted by malcolmh
    Hi,

    to backup both the database and the sugar directory with the ability to backup to a FTP server, try looking at the free tool phpMyBackPro
    A simple script, cron, and wput seem to do the job just fine. I'm interested in what needs to be backed up, not how to do it.

    Quote Originally Posted by Angel
    You should just backup the entire sugarcrm folder. Not because it is unavoidable, but because it is the simplest and most reliable way
    It seems rather wasteful to back up the software every day. I'm only interested in backing up what the users can change. -- the customised fields and forms being most of it (I guess).

    Quote Originally Posted by Angel
    If instead you choose to only backup the absolute minimum, you'll also need to constantly verify that no other files in any other sub-directory have been modified, which is just additional administrative overhead. Say for example that I modify some of the HTML in the ../modules/Contacts/EditView.html file, unless you know about needing to include that file too, the backup wouldn't pick it up.
    Can the users modify that? I'm the one that applies patches and software upgrades, the users simply use the software. Surely good design would suggest that the things which the users can modify (especially data) would be located in places that are easily backed up?

    Quote Originally Posted by Angel
    What I've done in the past (on Linux) is setup a cron job that runs a shell script which in turn creates a tar ball of the sugarcrm directory and zips it. Because the vast majority of the files are text, it zips rather well and adds little overhead to the overall backup file size.
    Yeah, I've tried that. At present such a backup is many times (about 26x) the size of the database dump :-(

    I guess the problem is that I've heard of people having problems if they simply back up the database -- One complaint was the loss of all custom fields (and maybe the data too?). Clearly, backups of the data need to be synchronised so that all I need to recover are the version of the software loaded (+ any patches) and the backup.

    If someone can point me to some documentation (if it exists) describing the locations of what the users can change via the user interface (I realise admin users can load software updates -- ignoring that) then I will happily RTFM.

    Looking through a number of threads, it seems the developers don't distinguish between volatile/non-volatile files and it may be best to go with the conservative approach.

  5. #5
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: Howto? Backup things not in database

    Quote Originally Posted by SteveH
    Looking through a number of threads, it seems the developers don't distinguish between volatile/non-volatile files and it may be best to go with the conservative approach.
    That was the point in my post. While backing up the software everyday may be a bit wasteful, the overhead is less than 20MB. Given the price of storage media nowadays, I'd venture to say that this is a trivial amount of data.

    And, like you've pointed out, the distinction between volatile/non-volatile files is virtually non-existent (aside from where they reside in the directory structure), which means you'll end up spending a lot of cycles trying to make that determination on your own. Doesn't seem worth the effort if the end result is just to save 20MB of space.

    EDIT: BTW, I am not sure how the size of that backup would be 26x larger than the MySQL dump. Thats seems a bit strange, unless you have a lot of stuff in the cache folder, in which case, your previous thought of backing up /cache wouldn't help reduce its size.
    Last edited by Angel; 2006-12-21 at 11:46 PM.
    Regards,

    Angel Magaña
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

  6. #6
    chrisky is offline Sugar Community Member
    Join Date
    Aug 2006
    Location
    Trondheim, Norway
    Posts
    293

    Smile Re: Howto? Backup things not in database

    If you'd like to determine which specific files are the ones of which can be customized by users and/or administrators in order to backup only those files (of which is very wise and logically sound, to me), they are right in pointing out that you'll spend more time, energy, and effort in determing which files these are; however, since nobody else has yet to share such, I'll go ahead and explain how you can identify those files.

    Firstoff, you'll want to modify the files, thus you'll want to perform any, and all possible functions and/or customizations in which you're able to (a few at a time).

    Second, you'll then want to recursively search the file structure for files modified that same day, and then sort the files by time modified.

    This will give you the information in which you're after.. Even moreso, you'll also be able to identify which specific directories in the file structure in which such modfied, edited, or customized files can be, or are, stored.

    Merry Christmas to all!

  7. #7
    SteveH is offline Junior Member
    Join Date
    Sep 2006
    Posts
    4

    Default Re: Howto? Backup things not in database

    Quote Originally Posted by Angel
    That was the point in my post. While backing up the software everyday may be a bit wasteful, the overhead is less than 20MB. Given the price of storage media nowadays, I'd venture to say that this is a trivial amount of data.
    Yes, And I guess it make restoring easier too.
    Quote Originally Posted by Angel
    BTW, I am not sure how the size of that backup would be 26x larger than the MySQL dump. Thats seems a bit strange, unless you have a lot of stuff in the cache folder, in which case, your previous thought of backing up /cache wouldn't help reduce its size.
    The gzipped database dump is around 1/4 MB, the gzipped tar of cache and custom dirs is also around 1/4 MB. The gzipped tar of the entire SugarCRM dir is around 6 Mb (and four sixes are twenty-four).

    For other systems I have running, I do a daily dump and hourly incremental backups. It looks like SugarCRM will be having only daily backups. I don't even know if I can do incremental backups with MySQL -- I guess I could use diff or something against the previous backup <shrug>
    Quote Originally Posted by chrisky
    If you'd like to determine which specific files are the ones of which can be customized...
    ...much removed...
    Quote Originally Posted by chrisky
    This will give you the information in which you're after..
    Thanks. It seems that the areas I'm interested in are:

    cache/
    custom/
    modules/
    data/
    (and the log file in the root)

    This limits the backup to about 1.5 Mb of files
    Quote Originally Posted by chrisky
    Merry Christmas to all!
    Thanks -- and you guys have a good one too.

    Steve

    p.s. This may be a solution. I have created 3 scripts, Full, Partial, and Incremental backups.

    Full -- backs up all data and files (I'll run this once a week)
    Partial -- backs up all data and files changed since last full backup (I'll run this daily)
    Incremental -- backs up a diff of the data and files changed since the last partial backup (hourly)

    There's a problem with the dump of the database. I need to replace "),(" with "),<eol>(", and I do this with sed. If I don't do this, the diffs end up twice the size of the data files when there's changes! I'll need to test that the extra <eol>s doesn't break the SQL (It shouldn't).

    Here's the scripts as they are now:

    sugar-full-backup.sh
    Code:
    #!/bin/sh
    #
    # do a full backup of SugarCRM -- All data, all files
    #
    dir=/var/backup/sugarcrm/
    datum=$(date +%Y-%m-%d__%H-%M-%S__)
    fullflag=${dir}.last-full-backup
    partialflag=${dir}.last-partial-backup
    lastsqlbackup=${dir}lastbackup.sql
    #
    # touch last backup time
    #
    touch ${partialflag}
    touch ${fullflag}
    #
    # database backup
    #
    name=sugarcrm-full-backup.sql
    file=${dir}${datum}${name}
    /usr/bin/mysqldump sugarcrm --complete-insert -u user -ppassword --flush-logs --opt --add-locks >${file}
    sed 's/),(/),\n(/g' <${file} >${lastsqlbackup}
    /bin/gzip -f ${file}
    #
    # backup all files
    #
    name=sugarcrm-full-backup.tar
    file=${dir}${datum}${name}
    cd /var/www/sugar
    tar -cf ${file} *
    /bin/gzip -f ${file}
    #
    # Transfer to backup storage
    #
    cd ${dir}
    wput -u -R ${datum}* ftp://user:password@server/backup/database/sugar/
    sugar-partial-backup.sh
    Code:
    projector:/etc/backup# cat sugar-partial-backup.sh
    #!/bin/sh
    #
    # do a partial backup of SugarCRM -- All data, files changed since last full backup
    #
    dir=/var/backup/sugarcrm/
    datum=$(date +%Y-%m-%d__%H-%M-%S__)
    fullflag=${dir}.last-full-backup
    partialflag=${dir}.last-partial-backup
    lastsqlbackup=${dir}lastbackup.sql
    #
    # touch last backup time
    #
    touch ${partialflag}
    #
    # database backup
    #
    name=sugarcrm-partial-backup.sql
    file=${dir}${datum}${name}
    /usr/bin/mysqldump sugarcrm --complete-insert -u user -ppassword --flush-logs --opt --add-locks >${file}
    sed 's/),(/),\n(/g' <${file} >${lastsqlbackup}
    /bin/gzip -f ${file}
    #
    # backup files since last full backup
    #
    set LAST_UPDATE = `ls -l ${fullflag} | awk '{print "since",$6,$7,$8}'`
    name=sugarcrm-partial-backup.tar
    file=${dir}${datum}${name}
    cd /var/www/sugar
    find . -type f -newer ${fullflag} -print >> /tmp/tar$$
    tar -cf ${file} -T /tmp/tar$$
    /bin/gzip -f ${file}
    #
    # Transfer to backup storage
    #
    cd $dir
    wput -u -R ${datum}* ftp://user:password@server/backup/database/sugar/
    and finally sugar-incremental-backup.sh
    Code:
    #!/bin/sh
    #
    # do a incremental backup of SugarCRM -- changed data and files since last backup
    #
    dir=/var/backup/sugarcrm/
    datum=$(date +%Y-%m-%d__%H-%M-%S__)
    fullflag=${dir}.last-full-backup
    partialflag=${dir}.last-partial-backup
    lastsqlbackup=${dir}lastbackup.sql
    #
    # database backup
    #
    name=sugarcrm-incremental-backup.sql
    file=${dir}${datum}${name}
    /usr/bin/mysqldump sugarcrm --complete-insert -u user -ppassword --flush-logs --opt --add-locks >${file}
    mv ${file} ${file}x
    sed 's/),(/),\n(/g' <${file}x >${file}
    rm ${file}x
    diff -u ${lastsqlbackup} ${file} > ${file}.diff
    /bin/gzip -f ${file}.diff
    rm ${file}
    #
    # backup files since last partial backup
    #
    set LAST_UPDATE = `ls -l ${partialflag} | awk '{print "since",$6,$7,$8}'`
    name=sugarcrm-incremental-backup.tar
    file=${dir}${datum}${name}
    cd /var/www/sugar.conexio-genomics.com
    find . -type f -newer ${partialflag} -print >> /tmp/tar$$
    tar -cf ${file} -T /tmp/tar$$
    /bin/gzip -f ${file}
    #
    # Transfer to backup storage
    #
    cd $dir
    wput -u -R ${datum}* ftp://user:password@server/backup/database/sugar/
    If I want to recover from an incremental backup, I'll need to use patch, but that's not a huge issue.

    Currently a full backup backs up everything (so about 6M + data)
    A partial, with no changed files is a 95 byte file and the gzipped data
    An incremental with no changes is 2 files, 289 bytes and 99 bytes.

    The weakness of this is that the backup doesn't record deleted files, so if you have to restore from a set of backups, you might end up with a few fils that were deleted between the full backup and the partial/incremental backup(s) used.

  8. #8
    tdp
    tdp is offline Sugar Community Member
    Join Date
    Sep 2005
    Posts
    74

    Default Re: Howto? Backup things not in database

    Can I ask why your not using rsync? If one of the criteria is to backup only the modified files, I would think that it is the perfect tool as that is one of the things it was designed to do.
    Todd Pihl

    Human Worklfows LLC
    Rockville, Maryland USA

    Slackware 11.0 running kernel 2.6.17.6
    MySQL 5.0.24a
    PHP 5.1.6
    Apache 1.3.37

  9. #9
    SteveH is offline Junior Member
    Join Date
    Sep 2006
    Posts
    4

    Default Re: Howto? Backup things not in database

    Quote Originally Posted by tdp
    Can I ask why your not using rsync? If one of the criteria is to backup only the modified files, I would think that it is the perfect tool as that is one of the things it was designed to do.
    I'm not sure that rsync would give me the opportunity to restore to any point in time without having what is effectively a complete backup at each point in time.

    The problem is that you want to restore to a point just prior to any problem. If the problem is a hardware failure, that point is obvious, and perhaps you could do no further backups after the failure. However, if the problem is a user deleting a heap of data, it may not come to light for some time.

    Steve

  10. #10
    pierre123 is offline Member
    Join Date
    May 2007
    Posts
    9

    Default Re: Howto? Backup things not in database

    Hi, probably this is something for you.
    http://www.sugarforge.org/projects/databasebackup/

    You can make small or big backups of sugarcrm, and you can choose to do it everyday or something else. Am not sure.
    Succes!

Thread Information

Users Browsing this Thread

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

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
  •