Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Newbie to Mac stuff

Featured Replies

Hi,

We just installed a new mac mini server which will be used to host our FM files.

The files were before on a Windows server with FMS11. There was a VBScript that copied the backup files which were local to a remote folder.

Is there way I can use the same script? or I need to redo the script with AppleScript?

I really don't know anything about AppleScript. Is there a more developer friendly language, i.e. a standard scripting language (VB, JavaScript, C, ...)

Thanks

  • Author

Just done a perl script to send backups to an external drive. Works pretty well for my needs.

Here's the code. Someone might find it useful.


#!/usr/bin/env perl -w

use strict;

use warnings;

use DirHandle;

#use Compress::ZLib;

use Archive::Zip qw (:ERROR_CODES);

use File::Copy;

use POSIX;



#Declarations

sub main(@);

sub getLastFile (@);

sub copy_recursively;

sub compress (@);





#Main program call

main();





sub main (@) {

	

	#Source folder

	my $dir = '/Volumes/Server HD/Library/FileMaker Server/Data/Backups/dbFolder';

		

	#getting last created folder

	my $newest = getLastFile ($dir);

	

	#creating the destination zip filename

	my $fn_body = "a_filename";

	my $suffix = "_" . POSIX::strftime('%Y%m%d', localtime) . ".zip";

	my $dir_to = '/Volumes/usb_hd_raid/backups/fm/';

	

	my $fn_full = $dir_to . $fn_body . $suffix;

	

	

	my ($source, $target) = ($newest, $fn_full);

	

	#my $re = qr/".*"/;

	#copy_recursively ($source, $target, $re);	

	

	

	print "Compression of $fn_body started.n";

	compress ($source, $target);

	print "Compression donen";

	

}



#Returns the fullname of the last file in a given folder.

sub getLastFile (@){

	my $dir = $_[0];

	my $dir_handle = new DirHandle $dir or die "Unable to open $dir $!";

	my $file;



	my %newest; #Hash declaration



	$newest {mtime} = 0; #Set key mtime to 0



	while (defined($file = $dir_handle->read)){

		next if ($file eq '.' or $file eq '..');

		my $mtime = (stat("$dir/$file"))[9]; #Gets the modification time

		$newest {file} = $file and $newest{mtime} = $mtime if $newest{mtime} < $mtime;

	}

	

	return $dir . "/" . $newest{file};

}



#Create a Zip file from the given source and to the targeted file.

sub compress (@) {

    my $src = $_[0];

    my $dst = $_[1];

    

    my $zip = Archive::Zip->new();

    

    #Add a directory

    my $dir_member = $zip->addTree($src);   

    

    

    #save zip file

    unless ($zip->writeToFileNamed($dst) == AZ_OK)

    {

        die "read error $!";

    }      

}

Edited by Guest

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.