mobizt / Firebase-ESP32

[DEPRECATED]🔥 Firebase RTDB Arduino Library for ESP32. The complete, fast, secured and reliable Firebase Arduino client library that supports CRUD (create, read, update, delete) and Stream operations.
MIT License
415 stars 118 forks source link

Restore Error: Could not read/write backup file #16

Closed GuilhermeKROSS closed 5 years ago

GuilhermeKROSS commented 5 years ago

Hi, I'm trying to use the restore function, but is returning me:

REASON: Could not read/write backup file

The backup is working fine, and the file is being created in my SD card. I just cant restore this file. I created a edited a little the exemple code to post here:

` //Define Firebase Data object FirebaseData firebaseData;

void setup() {

Serial.begin(115200);

WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("Connecting to Wi-Fi"); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(300); } Serial.println(); Serial.print("Connected with IP: "); Serial.println(WiFi.localIP()); Serial.println();

Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); Firebase.reconnectWiFi(true);

//Print to see stack size and free memory UBaseType_t uxHighWaterMark = uxTaskGetStackHighWaterMark(NULL); Serial.print("Stack: "); Serial.println(uxHighWaterMark); Serial.print("Heap: "); Serial.println(esp_get_free_heap_size());

Serial.println("------------------------------------"); Serial.println("Backup test...");

//Provide specific SD card interface //Firebase.sdBegin(14, 2, 15, 13); //SCK, MISO, MOSI,SS for TTGO T8 v1.7 or 1.8

//Download and save data at defined database path to SD card. //{TARGET_NODE_PATH} is the full path of database to backup and restore.

if (!Firebase.backup(firebaseData, "/ESP32_Test", "/bk")) { Serial.println("FAILED"); Serial.println("REASON: " + firebaseData.fileTransferError()); Serial.println("------------------------------------"); Serial.println(); } else { Serial.println("PASSED"); Serial.println("BACKUP FILE: " + firebaseData.getBackupFilename()); Serial.println("FILE SIZE: " + String(firebaseData.getBackupFileSize())); Serial.println("------------------------------------"); Serial.println(); }

Serial.println("------------------------------------"); Serial.println("Restore test...");

//Restore data to defined database path using backup file on SD card. //{TARGET_NODE_PATH} is the full path of database to restore

if (!Firebase.restore(firebaseData, "/ESP32_Test", "/bk/ESP32_Test.json")) { Serial.println("FAILED"); Serial.println("REASON: " + firebaseData.fileTransferError()); Serial.println("------------------------------------"); Serial.println(); } else { Serial.println("PASSED"); Serial.println("BACKUP FILE: " + firebaseData.getBackupFilename()); Serial.println("------------------------------------"); Serial.println(); }

//Quit Firebase and release all resources Firebase.end(firebaseData);

}

void loop() { }`

mobizt commented 5 years ago

On restore, you not need to assign file name, just the path in SD card that you assigned to save the backup file.

Because the restore file name is reconstruct from node path and append .json as file extension.

Then if you assign "/bk/ESP32_Test.json" as file path and node path is "/ESP32_Test",, the reconstructed file name will be "/bk/ESP32_Test.json/ESP32_Test.json" which is not exist.

The correct restore path should be "/bk" which the same as backup path and the valid call should be

Firebase.restore(firebaseData, "/ESP32_Test", "/bk")

Information in readme about restore path is also not right and I already correct it.