6 Replies Latest reply on Oct 7, 2014 1:59 PM by charleshuff

    zip and move filemaker backup on Mavericks?

    charleshuff

      In the remote past I had a folder action applescript that would watch the weekly backup folder and zip and move the files added to it recursively...

       

      Now it fails asking for my authentication password. I really need the script to run automaticly, so I am asking if it is still possible to do this on Mavericks?

       

      My trials with Automator so far have failed (largely due to the lack of the create dated folder automator action on my server!) as I need to copy the files into a dated folder before the zip process, then finally moving the zip file to a NAS drive for burning to dvd.

       

      We burn the weekly zip files to comply with offsite backups. Hourly and Daily Backups are working (but these processes are done entirely by filemaker and do not use folder actions).

       

      Thanks for any ideas in advance..

       

      Charles

        • 1. Re: zip and move filemaker backup on Mavericks?
          Mike Duncan

          Does this also fail if there is no user currently logged in? You can zip and move files with a shell script instead, and schedule it to run. You can get quite sofisticated in the scripting, but here's a few basic lines to get you started, you would save this as a text file named "backup_fm.sh" for example...

           

          # create a zip of the backups folder

          ditto -c -k --keepparent --rsrc /Library/FileMaker\ Server/Data/Backups/ /Library/FileMaker\ Server/Data/DB_Backups.zip

           

          # move to archive folder on backup drive, renamed with date string

          mv /Library/FileMaker\ Server/Data/DB_Backup.zip /Volumes/Backup/Archive/DB_`date +%Y%m%d`.zip

          • 2. Re: zip and move filemaker backup on Mavericks?
            charleshuff

            I found this post elsewhere:

             

            http://www.sumware.net/robfm3/?p=27 and it is very close to your answer...

             

            It creates symlinks and uses ditto to zip the backup.  Got that working.  It then uses cp (not mv) to create the dated zip file.

             

            I could not get the mkdir, mount_afp, cp, unmount, find, and delete to work.  (I tried for several hours...)

             

            I ended up using ditto to zip directly to the network share and commented out all the stuff after ditto except the rm -f $sourcelink and

            rm -f $destinationlink...  It works but takes a long time to run.

             

            Is that bad?  Is there a danger of timeouts? Using ditto straight to the network share seems less complicated! Should I keep on trying or do you think this will be ok?

             

            I added the manually mounted folder to my startup options, so the folder gets automounted on server reboot.  I wish I knew enough to fix the script or at least add some kind of error checking if it times out...  maybe send myself an email...   I will keep looking for an example.

             

            I see other posts talking about FTP the backup to another server...  Is that a better solution?  I think it requires a plugin and it seems more complicated...

             

            Thanks for helping me get this going...

            • 3. Re: zip and move filemaker backup on Mavericks?
              wimdecorte

              charleshuff wrote:

               

              Using ditto straight to the network share seems less complicated! Should I keep on trying or do you think this will be ok?

               

              You're making the process muchlonger than it needs to be.  Zipping locally and then moving a smaller file across the network is going to be much faster and thus less prone to interruptions.

               

               

               

               

              I see other posts talking about FTP the backup to another server...  Is that a better solution?  I think it requires a plugin and it seems more complicated...

               

               

              Plugins are for doing things INSIDE a FileMaker solution.  Not for backups and the like.  FTP can be scripted through the OS, just like moving a file to a network share.  FTP can be somewhat easier because it does not rely on mounting a drive first.  But then again, using a SMB share on the network does not either.

               

              Rob's link was part of an old write-up on backups: http://www.filemaker-solutions.be/IMG/pdf/MoreBackups_v2.pdf, there might be some useful additional info there.

              • 4. Re: zip and move filemaker backup on Mavericks?
                Mike Duncan

                You are likely running into permission issues if you are running the script from fmserver. When I run such scripts, I schedule it using crontab and run locally as root. I usually feel safe enough running as root on the local machine, but if you really want to, you can also give permissions to the fmserver user by added only the specified programs you might want to the sudoers file. Then you can sudo in your shell script and it will be able to run from there, if need be. To do that, you run the command "sudo visudo" (no, that's not a Phil Collins song, ha).

                 

                Note, if you don't know vi to edit text files via terminal in OS X, take 15-20 minutes and run through the tutorial for vim (vi improved) by running this from a terminal: vimtutor

                 

                Wim is right about zipping locally and then copying, but I personally wouldn't use FTP, I would either use secure copy (scp) to another mac or do a file copy to an smb volume if it is a windows share. SCP is an ssh tool, so if you use that, there are a couple extra steps to take so you don't have to log in, but these are part of the ssh standard. If you go this route, here's the necessary lines to set that up (hit enter three times to accept the defaults for the first command):

                 

                # ssh-keygen -d

                # cat ~/.ssh/id_dsa.pub | ssh account_name@server_ip 'cat - >> ~/.ssh/authorized_keys'

                # cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

                 

                Then after you run ditto, the line to secure copy to another server looks like this:

                 

                scp -B /Library/FileMaker\ Server/Data/DB_Backup.zip account_name@server_ip:/Database_Backups/DB_Backup.zip

                 

                 

                 

                I'm not sure, Wim, about not having to mount the smb volume, at least in Mac OS. What I was able to get working was to have a folder on the desktop that I used as a mount point. Once attached, I could copy over files and then use an unmount command to disconnect. I would not connect to the remote share as an admin, I would recommend creating a lower privilege set account there called "backup" or something that allows you to write files in the specified place.

                 

                For SMB shares, here's what I had working, with a local user account called "admin":

                 

                # mount the remote volume with the appropriate information, the w flag and workgroup name are only if needed.

                /sbin/mount_smbfs -W WORKGROUP_NAME //backup_account:password@server_ip/Backups /Users/admin/Desktop/SMB

                # copy the folder to back up

                cp -R /Users/admin/Desktop/SMB/ /Users/admin/Desktop/path_to_backup/

                # unmount the remote volume

                /sbin/umount /Users/admin/Desktop/SMB

                 

                 

                Hope this helps, if only just a little bit.

                Mike

                • 5. Re: zip and move filemaker backup on Mavericks?
                  wimdecorte

                  Mike Duncan wrote:

                   

                   

                  I'm not sure, Wim, about not having to mount the smb volume, at least in Mac OS.

                   

                  On OSX you can use "smbclient" to get around mounting the smb share, it has a put command.

                  The network share can then be defined in the UNC format:

                  networkshare="//serverIPorDNS/someSharedFolder/"

                  • 6. Re: zip and move filemaker backup on Mavericks?
                    charleshuff

                    I tried many times to get cp, scp, mv, to work.  Everyone's advice was spot on...  It is much faster to zip to another local folder then copy to the network share.  The ssh-keygen -d never did work for me, I was prompted with a list of options and -d was not there.  I tried -D also (it was there!) but that didn't help.  Ditto was working for me much faster after I pointed it to a local folder destination so I tried setting up a folder action automator script to move the zip file.  That seems to be working just fine, as long as the drive is 'mounted' upon startup...

                     

                    The only thing I didn't get to work was the email to me when it fails...  But I did make an entry in my iCal to remind me to go and look to see if the zip got moved...   That seems to be as close as I will come to my ideal solution.

                     

                    Many thanks to both Wim and Mike...