regexaurus
Forum Replies Created
-
One approach to keeping your Google Drive backups (more) secure in the event your web site is hacked:
- Share the UpdraftPlus folder with a second Google account. View access is fine. If you want to remove the source files after copying to the second account, grant edit access.
- On your second Google account, create an unshared folder (e.g. UpdraftPlusCopy).
- On your second Google account, go to script.google.com. Copy/paste the following (I renamed myFunction to CopyNewFiles) and replace the [bogus] folder IDs with the folder IDs for your source/destination folders:
function CopyNewFiles() {
var SourceFolder = DriveApp.getFolderById(‘JMtgsgM9sY9Fe5Z7wCbb4YVVqfeZiZ’);
var SourceFiles = DriveApp.getFolderById(‘JMtgsgM9sY9Fe5Z7wCbb4YVVqfeZiZ’).getFiles();
var DestFolder = DriveApp.getFolderById(‘SFGXwgvX6DmkAvPrrnWC2KY3imy7s2’);
var DestFiles = DriveApp.getFolderById(‘SFGXwgvX6DmkAvPrrnWC2KY3imy7s2’).getFiles();
var NotInDest = true;
while (SourceFiles.hasNext()) {
SourceFile = SourceFiles.next();
while (DestFiles.hasNext()) {
DestFile = DestFiles.next();
if (SourceFile.getName() === DestFile.getName()) {
NotInDest = false;
}
}
if (NotInDest) {
SourceFile.makeCopy(SourceFile.getName(), DestFolder);
NotInDest = true;
}
DestFiles = DriveApp.getFolderById(‘SFGXwgvX6DmkAvPrrnWC2KY3imy7s2’).getFiles();
}
} - Optionally, rename the project. Save it (Ctrl+S) works and click the Run button.
The first time you run it, you should be prompted to grant the script access to manage your (second Google account) Drive.
The script above will copy all files from SourceFolder to DestFolder that don’t already exist (identically-named file) exist in the DestFolder. If you are concerned about storage limits/cost, you could update the script to remove the original file after copying (example below). With that approach, you can remove/comment the code that checks for identically-named files in DestFolder, since that should never be the case if you remove the original file in SourceFolder. To do a restore from the UpdraftPlus plugin, you would need to copy/move the backup files back to the UpdraftPlus folder on the first Google account.
function CopyNewFiles() {
var SourceFolder = DriveApp.getFolderById(‘JMtgsgM9sY9Fe5Z7wCbb4YVVqfeZiZ’);
var SourceFiles = DriveApp.getFolderById(‘JMtgsgM9sY9Fe5Z7wCbb4YVVqfeZiZ’).getFiles();
var DestFolder = DriveApp.getFolderById(‘SFGXwgvX6DmkAvPrrnWC2KY3imy7s2’);
while (SourceFiles.hasNext()) {
SourceFile = SourceFiles.next();
SourceFile.makeCopy(SourceFile.getName(), DestFolder);
SourceFolder.removeFile(SourceFile);
}
}For Google Drive, if you’re a G Suite customer, consider using Vault (if available for your account) for additional protection in the event your web site is hacked and your Google Drive backups deleted.
I think another possibility is to share the UpdraftPlus folder with another Google user, and in the second account’s Drive, regularly copy the contents of the shared folder to a different folder only accessible to the second account/user. You could probably automate the copying with a Google Script and trigger (e.g. daily). I will test this and try to come up with a simple script.@dnutbourne, I joined the Group as suggested (and left the Group shortly thereafter, as recommended). When I went to UpdraftPlus settings to redo authentication/authorization for the web app to access my Drive, I noticed the “Google Drive: Account is not authorized” message had disappeared. Out of curiosity, I checked my UpdraftPlus folder, and it contained backup files from last evening (6/4/2017)! UpdraftPlus is configured for daily backup…
I will keep an eye on this to see if backup files continue to transfer to my Drive. I guess this is tentatively resolved. Seems like the experience could be smoother, but maybe this is related to Google tightening the OAuth screws, since the recent phishing scam targeting OAuth authorization…?Thank you!