dae1804 / bareos-file-backup-to-amazon-s3

App for automatically migrating Bareos file-based backups to the Amazon S3 cloud. Confidentiality and integrity are ensured by encrypting the data client-side using an authenticating encryption cipher.
Other
5 stars 0 forks source link

Unable to access jarfile #1

Closed nerionsis closed 5 years ago

nerionsis commented 5 years ago

Hello,

I have followed your instructions in a Bareos under CentOS installation, but when I run a job I get this error:

25-feb 16:46 l5dev-fd JobId 63: shell command: run ClientAfterJob "/usr/bin/java -jar /opt/SecureS3StorageForBareos-all.jar backup /var/lib/bareos/storage/s3 63 '%V'" 25-feb 16:46 bareos-sd JobId 63: Releasing device "S3BackupStorage" (/var/lib/bareos/storage/s3). 25-feb 16:46 bareos-sd JobId 63: Elapsed time=00:00:02, Transfer rate=7.409 M Bytes/second 25-feb 16:46 l5dev-fd JobId 63: ClientAfterJob: Error: Unable to access jarfile /opt/SecureS3StorageForBareos-all.jar 25-feb 16:46 l5dev-fd JobId 63: Error: Runscript: ClientAfterJob returned non-zero status=1. ERR=Child exited with code 1

dae1804 commented 5 years ago

What does running 'java -jar /opt/SecureS3StorageForBareos-all.jar' produce?

Did you install the built JAR to that path? (ls -l /opt/*.jar)

nerionsis commented 5 years ago

no main manifest attribute in /opt/SecureS3StorageForBareos-all.jar

[root@xxxxx]# ls -l /opt/*.jar -rw-r--r-- 1 bareos bareos 10030507 feb 25 17:34 /opt/SecureS3StorageForBareos-all.jar

nerionsis commented 5 years ago

If I change the way I call the jar file indicating the class which contains the main method tu run the program, it seems it works:

[root@xxxxx]# java -cp /opt/SecureS3StorageForBareos-all.jar com.daveeberhart.bareos_util.secure_s3_storage.Launcher Amazon S3 Storage for Bareos backups v.1.1

Move Bareos file-backup volumes into the Amazon S3 storage cloud, or copy them from S3 back to local disk.

Usage: Backup: java -jar BareosS3-all.jar backup /path/to/scratch/dir 123 volume1 [volume2 [volume3 [...]]] -or- Restore: java -jar BareosS3-all.jar restore-volumes /path/to/scratch/dir 234-volume1 [345-volume2 [456-volume3 [...]]] -or- Restore: java -jar BareosS3-all.jar restore-jobs /path/to/scratch/dir 234 [345 [456 [...]]] Where: backup/restore is the action to take /path/to/scratch/dir is the path you specified in the Bareos sd config 123 is the ID of the Bareos backup job volume1 (etc) are the name(s) of the Bareos disk volume file(s) 234 (etc) are the ID(s) of the Bareos job(s) to restore disk volumes for

nerionsis commented 5 years ago

So, if I modify the command line in the jobdef configuration file:

Command = "/usr/bin/java -cp /opt/SecureS3StorageForBareos-all.jar com.daveeberhart.bareos_util.secure_s3_storage.Launcher backup /var/lib/bareos/storage/s3 %i '%V'"

When I run the job, I still receive an error:

26-feb 10:49 l5dev-fd JobId 72: shell command: run ClientAfterJob "/usr/bin/java -cp /opt/SecureS3StorageForBareos-all.jar com.daveeberhart.bareos_util.secure_s3_storage.Launcher backup /var/lib/bareos/storage/s3 72 '%V'" 26-feb 10:49 bareos-sd JobId 72: Elapsed time=00:00:02, Transfer rate=7.409 M Bytes/second 26-feb 10:49 l5dev-fd JobId 72: ClientAfterJob: Error: cannot find or load main class com.daveeberhart.bareos_util.secure_s3_storage.Launcher 26-feb 10:49 l5dev-fd JobId 72: Error: Runscript: ClientAfterJob returned non-zero status=1. ERR=Child exited with code 1

dae1804 commented 5 years ago

Hmm... So Gradle isn't embedding the JAR manifest correctly, then.

Not sure why specifying the classpath and main class didn't work for you from Barros.

I'll look at this more tonight.

dae1804 commented 5 years ago

I believe I've traced the issue when using the -cp command to a documentation issue: you need to set Runs On Client = No on the after-job, otherwise the command runs on your client (filedaemon) instead of on the director. So, naturally your client PC couldn't find the JAR that was on your server, and wasn't able to replace the %V token with the list of volumes used (this is what caught my eye).

For reference, here's what the AfterJob output should look like:

26-Feb 21:42 batman-dir JobId 8753: shell command: run AfterJob "/usr/bin/java -jar /opt/SecureS3StorageForBareos-all.jar backup /var/lib/bareos/storage/s3 8753 'DAES3OFFSITE-2092'"
26-Feb 21:42 batman-dir JobId 8753: AfterJob: Amazon S3 Storage for Bareos backups v.1.2
26-Feb 21:42 batman-dir JobId 8753: AfterJob:
26-Feb 21:42 batman-dir JobId 8753: AfterJob: Now uploading volumes [DAES3OFFSITE-2092]
26-Feb 21:42 batman-dir JobId 8753: AfterJob: Encrypting volume DAES3OFFSITE-2092
26-Feb 21:42 batman-dir JobId 8753: AfterJob: Uploading volume DAES3OFFSITE-2092 as bb-8753-DAES3OFFSITE-2092.enc
26-Feb 21:42 batman-dir JobId 8753: AfterJob: [OK] Uploaded DAES3OFFSITE-2092 as ad8ff750d55b1339d37df90c481f8110
26-Feb 21:42 batman-dir JobId 8753: AfterJob: Done uploading 1 volumes...
26-Feb 21:42 batman-dir JobId 8753: AfterJob: Success!
26-Feb 21:42 batman-dir JobId 8753: AfterJob: Job execution completed normally.

I just published 1.2, which should fix the missing JAR manifest issue, and I'm updating the docs now. Can you rebuild, try changing back to a -jar invocation and adding Runs On Client = No, and let me know if that resolves your issue, please?

nerionsis commented 5 years ago

With the new release and including "Runs On Client = No" works perfectly.

Thank you!