Back up OpenOffice.org Documents on Amazon S3

Productivity Sauce
When it comes to cheap and secure off-site backup and storage, few services can beat Amazon S3. And if you want to easily back up your OpenOffice.org documents on Amazon S3, you can do so using a simple OpenOffice.org Basic macro and the aws Perl script. Before you start, you have to sign up for Amazon S3. Next, use your Linux distribution's package manager to install the curl utility. On a Ubuntu-based distro, this can be done using the sudo apt-get install curl command.
Now you can install aws. Download the latest version of the aws script and put it into your home directory. In the terminal, run the following command as root:
perl aws --install
Create an .awssecret text file in your home directory, and enter your Access Key ID on the first line and the Secret Access Key on the second line. Use then the s3mkdir command to create a new S3 bucket:
s3mkdir openoffice_org_backup_bucket
Note that the name of the bucket must be unique. Once aws is configured and ready to go, you start working on an OpenOffice.org macro that backs up the currently opened document on Amazon S3 via aws. The macro starts with obtaining the currently active document and checking whether it has already been saved. The latter is required to obtain the path to the document:
ThisDoc=ThisComponent If ThisDoc.hasLocation=False Then MsgBox ("You have to save to document first!", 16, "Attention!") :End End If
Next, the macro saves all unsaved changes in the document:
ThisDocURL=ThisDoc.getURL() If ThisDoc.isModified Then ThisDoc.storeAsURL(ThisDocURL, Args) End If
To construct a command that uploads the currently opened document, the macro needs to obtain two things: the document's path and name:
DocPath=ConvertFromURL(ThisDoc.getURL()) FileName=Dir(ThisDoc.getURL, 0)
To upload a file to Amazon S3, aws uses the s3put command which has the following format:
s3put BUCKET_NAME /path/to/file
The path/to/file part refers to the file or document you want to upload, while BUCKET_NAME refers to a bucket on Amazon S3 (in this case, it's openoffice_org_backup_bucket). So to construct the command that uploads the current OpenOffice.org document, the macro simply inserts the obtained DocPath value in a string which is then passed to the Shell routine:
PutCommand="openoffice_org_backup_bucket/" & FileName & " " & DocPath Shell("s3put", 1, PutCommand)
That's all there is to it. Here is the entire macro in all its beauty:
Sub AmazonS3Backup() Dim Args(0) As New com.sun.star.beans.PropertyValue ThisDoc=ThisComponent If ThisDoc.hasLocation=False Then MsgBox ("You have to save to document first!", 16, "Attention!") :End End If ThisDocURL=ThisDoc.getURL() If ThisDoc.isModified Then ThisDoc.storeAsURL(ThisDocURL, Args) End If DocPath=ConvertFromURL(ThisDoc.getURL()) FileName=Dir(ThisDoc.getURL, 0) PutCommand="openoffice_org_backup_bucket/" & FileName & " " & DocPath Shell("s3put", 1, PutCommand) End Sub
Comments
comments powered by DisqusIssue 272/2023
Buy this issue as a PDF
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
News
-
KDE Plasma 6 Looks to Bring Basic HDR Support
The KWin piece of KDE Plasma now has HDR support and color management geared for the 6.0 release.
-
Bodhi Linux 7.0 Beta Ready for Testing
The latest iteration of the Bohdi Linux distribution is now available for those who want to experience what's in store and for testing purposes.
-
Changes Coming to Ubuntu PPA Usage
The way you manage Personal Package Archives will be changing with the release of Ubuntu 23.10.
-
AlmaLinux 9.2 Now Available for Download
AlmaLinux has been released and provides a free alternative to upstream Red Hat Enterprise Linux.
-
An Immutable Version of Fedora Is Under Consideration
For anyone who's a fan of using immutable versions of Linux, the Fedora team is currently considering adding a new spin called Fedora Onyx.
-
New Release of Br OS Includes ChatGPT Integration
Br OS 23.04 is now available and is geared specifically toward web content creation.
-
Command-Line Only Peropesis 2.1 Available Now
The latest iteration of Peropesis has been released with plenty of updates and introduces new software development tools.
-
TUXEDO Computers Announces InfinityBook Pro 14
With the new generation of their popular InfinityBook Pro 14, TUXEDO upgrades its ultra-mobile, powerful business laptop with some impressive specs.
-
Linux Kernel 6.3 Release Includes Interesting Features
Although it's not a Long Term Release candidate, Linux 6.3 includes features that will benefit end users.
-
Arch-Based blendOS Features Cool Trick
If you're looking for a Linux distribution that blends Linux, Android, and web apps together, blendOS might be what you're looking for.
Why not use the Sun Cloud?