public void run(CopyToolConfig config) throws Exception
	{
		if (config == null)
		{
			throw new CopyToolException("CopyToolConfig cannot be null");
		}
		this.config = config;
		
		// load database drivers
		loadDatabaseDrivers();
		CopyToolConnectionManager.getInstance().setConfig(config);
		
		// how should we run? with scheduler (i.e. infinite) or one-time
		if (config.isSchedulerEnabled()) 
		{
			int interval = config.getSchedulerInterval() * 1000;
			int timeLeft = interval;
			
			while(true)
			{
				// do copy
				try {
					doCopy();
				} catch (Exception e) {
					// we catch every exception because we don't want to fail
					// out of the scheduler
					LOG.error("Caught exception: " + e.getMessage(), e);
					EmailUtil.sendMail(e, this.config.getDatabaseProperties());
					CopyToolConnectionManager.getInstance().closeConnections();
				}

				LOG.info("Scheduling enabled, sleeping for " + (interval/1000) + " seconds until next run");
				timeLeft = interval;
				
				// sleep in increments of 5 minutes
				while(timeLeft > 0)
				{
					// do sleep
					try {
						Thread.sleep((timeLeft > SLEEP_INCREMENT) ? SLEEP_INCREMENT : timeLeft);
					} catch (InterruptedException e) {
						LOG.warn("Scheduled waiting time got interrupted!");
					}
					
					timeLeft = timeLeft - SLEEP_INCREMENT;
					if (timeLeft > 0)
						LOG.info("Still sleeping " + (timeLeft/1000) + " seconds until next run");
				}
				
				LOG.info("Starting next run!");
			}
		}
		else
		{
			// do one-time copy
			doCopy();
		}
	}