Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Wasabi cloud storage #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions ArqRestoreCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,22 @@ - (BOOL)addTarget:(NSArray *)args error:(NSError **)error {
NSString *oAuth2ClientSecret = nil;
NSString *oAuth2RedirectURI = nil;

if ([targetType isEqualToString:@"aws"]) {
if ([targetType isEqualToString:@"aws"] || [targetType isEqualToString:@"wasabi"]) {
if ([args count] != 5) {
SETNSERROR([self errorDomain], ERROR_USAGE, @"invalid arguments");
return NO;
}

NSString *accessKeyId = [args objectAtIndex:4];
AWSRegion *usEast1 = [AWSRegion usEast1];
NSString *urlString = [NSString stringWithFormat:@"https://%@@%@/any_bucket", accessKeyId, [[usEast1 s3EndpointWithSSL:NO] host]];
NSString *urlString = [NSString stringWithFormat:@"https://%@@s3.wasabisys.com/any_bucket", accessKeyId];

if ([targetType isEqualToString:@"aws"]) {
AWSRegion *usEast1 = [AWSRegion usEast1];
urlString = [NSString stringWithFormat:@"https://%@@%@/any_bucket", accessKeyId, [[usEast1 s3EndpointWithSSL:NO] host]];
}
endpoint = [NSURL URLWithString:urlString];
secret = [self readPasswordWithPrompt:@"enter AWS secret key:" error:error];
NSString *prompt = [NSString stringWithFormat:@"enter %@ secret key:", [targetType isEqualToString:@"aws"] ? @"AWS" : @"Wasabi"];
secret = [self readPasswordWithPrompt:prompt error:error];
if (secret == nil) {
return NO;
}
Expand Down Expand Up @@ -648,7 +652,7 @@ - (BackupSet *)backupSetForTarget:(Target *)theInitialTarget computerUUID:(NSStr
- (NSArray *)expandedTargetListForTarget:(Target *)theTarget error:(NSError **)error {
NSArray *targets = nil;

if ([theTarget targetType] == kTargetAWS) {
if ([theTarget targetType] == kTargetAWS || [theTarget targetType] == kTargetWasabi) {
targets = [self expandedTargetsForS3Target:theTarget error:error];
} else {
targets = [NSArray arrayWithObject:theTarget];
Expand Down
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Use arq_restore to list the computers backed up to your destination, list folder

Type `arq_restore` with no arguments to get help.

arq_restore works with Arq backups on AWS or a local filesystem. If you need to restore from backups stored at a different cloud provider, download the backup data to a local filesystem and use arq_restore on that.
arq_restore works with Arq backups on AWS, Wasabi or a local filesystem. If you need to restore from backups stored at a different cloud provider, download the backup data to a local filesystem and use arq_restore on that.


## Prerequisites
Expand Down
1 change: 1 addition & 0 deletions Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

enum TargetType {
kTargetAWS = 0,
kTargetWasabi = 6,
kTargetLocal = 12
};
typedef int TargetType;
Expand Down
10 changes: 9 additions & 1 deletion Target.m
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,11 @@ - (BOOL)deleteOAuth2ClientSecret:(NSError **)error {

- (DictNode *)toPlist {
DictNode *ret = [[[DictNode alloc] init] autorelease];
[ret putString:@"s3" forKey:@"targetType"]; // Used by TargetFactory
if (targetType == kTargetWasabi) {
[ret putString:@"wasabi" forKey:@"targetType"]; // Used by TargetFactory
} else {
[ret putString:@"s3" forKey:@"targetType"]; // Used by TargetFactory
}
[ret putString:nickname forKey:@"nickname"];
[ret putString:uuid forKey:@"uuid"];
[ret putString:[endpoint absoluteString] forKey:@"endpointDescription"];
Expand Down Expand Up @@ -346,6 +350,10 @@ - (TargetType)targetTypeForEndpoint {
if ([[[self endpoint] scheme] isEqualToString:@"file"]) {
return kTargetLocal;
}
NSString *host = [[self endpoint] host];
if ([host hasSuffix:@"wasabisys.com"]) {
return kTargetWasabi;
}

return kTargetAWS;
}
Expand Down
2 changes: 1 addition & 1 deletion TargetConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ - (RemoteFS *)newRemoteFS:(NSError **)error {
return nil;
}

} else if (targetType == kTargetAWS) {
} else if (targetType == kTargetAWS || targetType == kTargetWasabi) {
AWSRegion *region = [AWSRegion regionWithS3Endpoint:[target endpoint]];
if (region == nil) {
region = [AWSRegion usEast1];
Expand Down
2 changes: 1 addition & 1 deletion TargetFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ - (Target *)targetWithPlistPath:(NSString *)thePath error:(NSError **)error {
return nil;
}
NSString *targetType = [[plist stringNodeForKey:@"targetType"] stringValue];
if ([targetType isEqualToString:@"s3"]) {
if ([targetType isEqualToString:@"s3"] || [targetType isEqualToString:@"wasabi"]) {
return [[[Target alloc] initWithPlist:plist] autorelease];
}
SETNSERROR([self errorDomain], -1, @"unknown target type '%@'", targetType);
Expand Down
1 change: 1 addition & 0 deletions arq_restore.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static void printUsage(const char *exeName) {
fprintf(stderr, "Usage:\n");
fprintf(stderr, "\t%s [-l loglevel] listtargets\n", exeName);
fprintf(stderr, "\t%s [-l loglevel] addtarget <nickname> aws <access_key>\n", exeName);
fprintf(stderr, "\t%s [-l loglevel] addtarget <nickname> wasabi <access_key>\n", exeName);
fprintf(stderr, "\t%s [-l loglevel] addtarget <nickname> local <path>\n", exeName);
fprintf(stderr, "\t%s [-l loglevel] deletetarget <nickname>\n", exeName);
fprintf(stderr, "\n");
Expand Down