PDA

View Full Version : How to back up AppData folder to OneDrive automatically?



kalmarjan
December 17th, 2016, 13:13
Not really a tech issue, but I recently needed to reinstall Windows 10 from a corrupted update. I backed everything up from my Documents folder, but totally forgot to back up my AppData folder. I lost ALL of my FG data in there.

If I wanted to have OneDrive automatically back up that folder periodically, does anyone know how I would do that?

Andraax
December 17th, 2016, 13:39
Try this: https://www.tenforums.com/tutorials/2905-onedrive-selective-sync-choose-folders-windows-10-a.html

Also, look at Carbonite. I prefer it over MicroSoft's solution... (If you're interested in Carbonite, drop me a PM, I'll send you a "refer a friend" code which will save you $20.)

Trenloe
December 21st, 2016, 20:14
DO NOT setup any sync application to point directly at your Fantasy Grounds app data directory. You can get corrupted data this way.

If you want something like this setup an offline backup/sync that only runs when FG is not running - i.e. copy files off somewhere else and then sync from there, or run a backup application when FG isn't running. Do not run OneDrive, Box, DropBox, Google Drive, etc. directly against your FG app data directory.

LindseyFan
December 22nd, 2016, 02:56
I feel your pain as I am a onedrive user... I think the cheapest backup solution you could run, that is highly reliable, is to plug a thumb drive in the back of your computer. At the end of every session (or even the start), simply copy it to a new folder on the thumb drive. The key is to copy to a new folder and not overwrite the old backup. This way if your backup fails, you have.. well.... a backup! :) after a month or two you can delete old saves. But always keep the most recent few. There are even better solutions that cost more, but this is the absolute cheapest alternative to cloud backups. (Cloud backup can be cheaper and better, but this is number 2)

Nylanfs
December 22nd, 2016, 03:11
What you could do is setup a batch file that will run FG, and then after FG exits copies the campaign folders to a synced location.

Andraax
December 22nd, 2016, 03:38
I think the cheapest backup solution you could run, that is highly reliable, is to plug a thumb drive in the back of your computer. At the end of every session (or even the start), simply copy it to a new folder on the thumb drive.

It's only highly reliable until the USB drive fails. If you use this solution, you should rotate between two or more USB drives, and keep one off-site (at work or a friend's house).

damned
December 22nd, 2016, 05:51
I agree with Andraax and Nylanfs here... USB keys are good until they are not or until the are lost.
Make a batch file to zip up your campaign folder and copy the zip to the One Drive path....

kalmarjan
December 22nd, 2016, 07:24
Would it be possible to put in a feature request for an update? Maybe a setting where you could say where you want to back it up after say, 5 closes?

kalmarjan
December 22nd, 2016, 07:25
What you could do is setup a batch file that will run FG, and then after FG exits copies the campaign folders to a synced location.

I would then run the batch file instead of the executable?

Zacchaeus
December 22nd, 2016, 11:40
I think that what might be helpful from those chaps suggestion running a batch file is further elucidation of what a batch file is and how would one go about creating such a thing and what would it consist of :)

Andraax
December 22nd, 2016, 12:28
I have CygWin installed, here is a batch file I use to run FG and backup to a RAID NAS (which is also backed to cloud storage) after each session:


set PATH=C:\cygwin64\bin;%PATH%
"C:\Program Files (x86)\Fantasy Grounds\FantasyGrounds.exe"

rem do a backup
bash ~/bin/backup_games


And my "backup_games" script:


#!/usr/bin/env bash
# vi:sw=2:ai

indir=/cygdrive/d/Fantasy\ Grounds/
outdir=linux:/mnt/public/games-backup/

rsync -Ca --delete-after --human-readable \
--info=BACKUP,COPY,DEL,NAME,STATS \
"$indir" "$outdir"

damned
December 22nd, 2016, 12:49
Ok.... ok....

Download this: https://www.7-zip.org/a/7za920.zip
and place the 7za.exe file in your c:\widows\system32 directory

Assuming your FG data file is in the (new) default location %AppData%\"fantasy grounds"
(The previous default location was %ProgramData%\"fantasy grounds")
And your OneDrive data file is in the default location %userprofile%\OneDrive
or your DropBox data is in the default location %userprofile%\dropbox

You can create a batch file like below... my compressed campaigns folder (after cleanup) is still over 200mb so work out what works for you...

Edit: Ive updated these... the initial error checking had some logic flaws so I removed them. Ive also changed it to backup all the XML files in the campaigns folder every time it runs and then to a separate file it will only add any changed data to the full campaigns backup (eg it will just update the existing zip file with new images/data). This only backups up \campaigns and no other folders.

This version will be much easier on your upload bandwidth after the first one syncs.

OneDrive


echo off


:BACKUP

:GETTIME
echo "GETTIME"
set hh=%time:~0,2%
if "%time:~0,1%"==" " set hh=0%hh:~1,1%
set dt=%date:~7,2%%date:~4,2%%date:~10,4%%hh%
echo %dt%

:BACKUPTARGET
echo "BACKUPTARGET"
echo %userprofile%\OneDrive\
if not exist %userprofile%\OneDrive\FGData mkdir %userprofile%\OneDrive\FGData

:BACKUPXMLFILES
echo "BACKUPXMLFILES"
echo %dt%
echo %ProgramData%\"fantasy grounds"\campaigns\
7za.exe a -tzip %userprofile%\OneDrive\FGData\%dt%.zip %AppData%\"fantasy grounds"\campaigns\*.xml -r

:BACKUPCAMPAIGNFILES
echo "BACKUPCAMPAIGNFILES"
if not exist %userprofile%\OneDrive\FGData\campaigns.zip 7za.exe a -tzip %userprofile%\OneDrive\FGData\%dt%.zip %AppData%\"fantasy grounds"\campaigns\*.xml -r
7za.exe u -tzip %userprofile%\OneDrive\FGData\campaigns.zip %AppData%\"fantasy grounds"\campaigns\*.* -r

:LISTFILES
echo "LISTFILES"
dir %userprofile%\OneDrive\FGData\
echo "Always double check that the backups have indeed worked!"
echo "Happy Gaming"
pause
EXIT


DropBox


echo off


:BACKUP

:GETTIME
echo "GETTIME"
set hh=%time:~0,2%
if "%time:~0,1%"==" " set hh=0%hh:~1,1%
set dt=%date:~7,2%%date:~4,2%%date:~10,4%%hh%
echo %dt%

:BACKUPTARGET
echo "BACKUPTARGET"
echo %userprofile%\DropBox\
if not exist %userprofile%\DropBox\FGData mkdir %userprofile%\DropBox\FGData

:BACKUPXMLFILES
echo "BACKUPXMLFILES"
echo %dt%
echo %appdata%\"fantasy grounds"\campaigns\
7za.exe a -tzip %userprofile%\DropBox\FGData\%dt%.zip %AppData%\"fantasy grounds"\campaigns\*.xml -r

:BACKUPCAMPAIGNFILES
echo "BACKUPCAMPAIGNFILES"
if not exist %userprofile%\DropBox\FGData\campaigns.zip 7za.exe a -tzip %userprofile%\DropBox\FGData\%dt%.zip %AppData%\"fantasy grounds"\campaigns\*.xml -r
7za.exe u -tzip %userprofile%\DropBox\FGData\campaigns.zip %AppData%\"fantasy grounds"\campaigns\*.* -r

:LISTFILES
echo "LISTFILES"
dir %userprofile%\DropBox\FGData\
echo "Always double check that the backups have indeed worked!"
echo "Happy Gaming"
pause
EXIT

kalmarjan
December 22nd, 2016, 15:54
Wanted to thank you guys! I tried this out and it does exactly what I need, except for one thing : I have to remember to think about clicking that batch file. If not, I'll let it slip. If only there was a way I could somehow attach a nag screen when FG closes-- then I'll back up for good luck.

Andraax
December 22nd, 2016, 16:01
Change the icon for FG to point to the batch file rather than the executable. This way, when you double click the icon, it runs the batch file.

LordEntrails
December 22nd, 2016, 18:48
You can also setup a scheduled task to run at logoff that runs the backup portion of the batch file. That way, every time you log off your computer, it will run your backup script first. (Though I'm not sure the dropbox or Onedrive backup would be completed before logoff, but then that would happen when you next log in.)

jasonthelamb
December 22nd, 2016, 20:33
I created a batch file that runs (using the windows timer) at a time when Fantasy Grounds is never up, it backs up my FG directory to Dropbox.

damned
December 22nd, 2016, 23:16
Edit: Ive updated my post above... the initial error checking had some logic flaws so I removed them. Ive also changed it to backup all the XML files in the campaigns folder every time it runs and then to a separate file it will only add any changed data to the full campaigns backup (eg it will just update the existing zip file with new images/data). This only backups up \campaigns and no other folders.

mlesnews
April 3rd, 2018, 19:56
*BUMP* Thanks for this @damned and everyone else. Great best practices method, "Thou shall backup!"

mrrockitt
May 14th, 2018, 21:59
Thanks from me too, Dropbox script works well. Only thing is and this might just be me, but I do not have an %Appdata% Fantasy Grounds folder on my Windows 10 Pro 64 bit laptop so I set it to backup ProgramData\Fantasy Grounds instead. Think this is right :)

Andraax
May 14th, 2018, 22:02
Well, that won't backup your campaign data... Check your settings to see where your data is stored.

Zacchaeus
May 14th, 2018, 22:12
Well, that won't backup your campaign data... Check your settings to see where your data is stored.


Thanks from me too, Dropbox script works well. Only thing is and this might just be me, but I do not have an %Appdata% Fantasy Grounds folder on my Windows 10 Pro 64 bit laptop so I set it to backup ProgramData\Fantasy Grounds instead. Think this is right :)

I think it does. I think the default location on Win 10 is ProgramData; but as Andraax says check in settings exactly here your FGData is stored (you can also get there by clicking the small folder icon to right of the start screen)

Trenloe
May 14th, 2018, 22:15
There was a period of time where FG's default data location was ProgramData\Fantasy Grounds (v3.0.13 to v3.1.7 - about 1 year) - but there were occasional access rights issues with this location. So the default was changed back to be under the AppData path. If you installed during the period when the default was ProgramData then that's what you'll use.

mrrockitt
May 14th, 2018, 22:35
Didn't think of that!

Yes, ProgramData is where my Campaign folder lives, not sure if that was default or I changed it!

Thanks

Andraax
May 14th, 2018, 23:59
I think it does. I think the default location on Win 10 is ProgramData; but as Andraax says check in settings exactly here your FGData is stored (you can also get there by clicking the small folder icon to right of the start screen)

The default location on Win10 is "%appdata%\Fantasy Grounds".

mrrockitt
May 15th, 2018, 09:18
Thanks all for the answers.
I am going to switch it back to %APPDATA% because you are right, it does throw up occasional complaints in ProgramData (have only just purchased Fantasy Grounds so new to it).

GrayMouser
December 28th, 2018, 20:47
Anyone test this on a MacBook macOS High Sierra yet?

As I understand the process, it backs up the campaign data so you have a fall back (EG - PC jacks up their character sheet). Assume you could import a single sheet from that backup. Or, would you delete the messed up sheet and copy over the backed up sheet into the active folder?

patriot101
January 3rd, 2020, 20:02
I noticed in my case, the data is saved in C:/Users/user/AppData/Roaming/Fantasy Grounds/

My user name is user....

It also looked like the default was to hide viewing of the folder AppData, so I had to make that viewable so I could look at it.

I guess the best thing is to look at the FG settings to see how it has setup the save location by default. That is what I did. I am looking at these batch file options, which look good. I would hate to lose all of my work.

I ended up making a simple batch file called Backup_FG.bat for my Windows 10 laptop. It has one line:

ROBOCOPY "C:\Users\user\AppData\Roaming\Fantasy Grounds" "C:\Users\user\Dropbox\Shared_Home\Fantasy Grounds Data" /mir

In my case, I only log in as one user while I am playing, so this works for me. This batch file isn't automated, although I will probably add that option because I am sure to forget to run it over time.

damned
January 3rd, 2020, 23:10
Welcome patriot101 - be aware that if something happened to your files stored locally and you did a /MIR it would update the dropbox copy with the (now) damaged files
Backups are generally recommended that you have multiple copies in case your current backup file is damaged (or has backed up damaged data)
Do consider expanding your one liner a little

SmackDaddy
February 24th, 2023, 19:52
Assuming your FG data file is in the (new) default location %AppData%\"fantasy grounds"
(The previous default location was %ProgramData%\"fantasy grounds")


Holy necro-thread batman....I know, I know....

So if I wanted to put the location into the batch file with the full path, how would this be done in the batch file you wrote?

My fantasy grounds folder isn't located in %appdata% if it's let's say: C:\Users\user\AppData\Roaming\SmiteWorks\fantasy grounds\
When I put in %appdata% it's looking where I used to have my FGC install, but FGU got installed to a different folder above -- "user" in that is my first name -- but when I use %appdata% that references a different username

Thanks in advance

Zacchaeus
February 24th, 2023, 20:02
Substitute your name for user.

damned
February 24th, 2023, 22:08
Continue to use %appdata% but be aware of when i posted this.
This was posted before FGU was a thing.
So the %appdata% bit is still correct but the rest of the path is wrong.

change all references of
%AppData%\"fantasy grounds"\

to
%AppData%\smiteworks\"fantasy grounds"\

SmackDaddy
February 24th, 2023, 22:22
And to clarify - %appdata% and %userprofile% aren't where my FGU files are located, those take me to a profile location that is where my FGC install was - my system is a bit borked and I really don't want to reinstall FG at this point -- just trying to figured out how to write out what is needed since %appdata%\"fantasy grounds" doesn't work (nor does \smiteworks\"fantasy grounds"\) -- do I just put the exact path in between "(quotes)" -- trying to just get the syntax correct....thank you.


Substitute your name for user.

lololol, I should've mentioned I put "user" instead of my actual name *smh*

damned
February 24th, 2023, 22:37
paths can often just be written

c:\users\john\OneDrive\FGData

but that is based on DOS which did not support spaces (among many other things) in folder and file names.
to get around that, and entry that contains a space needs to be wrapped in quotes

c:\users\"john wick"\"OneDrive - Retired Assassin"\FGData

Some commands will need a \ at the end otherwise it may read the last folder name as a filename

damned
February 24th, 2023, 22:40
%appdata% on 99.9% of windows computers refers to:

C:\Users\yourusernamehere\AppData\Roaming

%userprofile% on 99.9% of windows computers refers to

C:\Users\yourusernamehere